Using INotifyPropertyChanged with Entity Framework 6 DbContext Generator

dbcontext entity-framework-6 inotifypropertychanged

Question

Although I am aware that I could use ObjectContext instead, I prefer the functionality of DbContext and DbSet. I would like to implement change notification on the EF produced models directly because my application isn't big enough to warrant me building intricate view models.

How do I accomplish this?

1
7
9/17/2014 10:14:26 PM

Accepted Answer

ZZZ_tmp
2
6/17/2015 5:12:06 PM

Popular Answer

I've used a NuGet package named PropertyChanged with wonderful success. Fody to implement INPC on the entity class level. Simply add the [ImplementPropertyChanged] attribute to any class and PropertyChanged after installing the package. INPC will be "injected" into the class by Fody during the building process. Simply add the following code somewhere in your project if, for instance, your produced entity class is called Customer.

using PropertyChanged;

[ImplementPropertyChanged]
public partial class Customer
{
}

You can modify the functionality of the PropertyChanged package with additional attributes. Details can be found in https://github.com/Fody/PropertyChanged.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow