I find that a lot of the classes generated by EF (using the "Add Code Generation Item") EF 5.x DbContext Generator are great.
However, if you need to update any of these classes (by placing a foreignkey column or to flatten data from other classes), they are rendered useless.
You need to create ViewModel classes and place the code in there. If your model gets refreshed, I have to manually update my ViewModel classes that I created. You would also obviously lose your properties that you put in the generated class.
If there is a better way of reusing the generated classes from EF in the above type of scenario, I would love to hear about it....
The classes are partial so you can add properties etc in your own partial class. Also to declare meta data information you can use the
MetadataType attribute (for example for data annoatations) and declare the annotations in a seperate class.
Please remember to mark as Answer if the post helps you out.
wsyeager36
Member
385 Points
458 Posts
Refreshing the EntityFramework designer
Feb 22, 2013 08:30 PM|LINK
I find that a lot of the classes generated by EF (using the "Add Code Generation Item") EF 5.x DbContext Generator are great.
However, if you need to update any of these classes (by placing a foreignkey column or to flatten data from other classes), they are rendered useless.
You need to create ViewModel classes and place the code in there. If your model gets refreshed, I have to manually update my ViewModel classes that I created. You would also obviously lose your properties that you put in the generated class.
If there is a better way of reusing the generated classes from EF in the above type of scenario, I would love to hear about it....
Bill Yeager
MCP.Net, BCIP
Talal Tayyab
Participant
902 Points
132 Posts
Re: Refreshing the EntityFramework designer
Feb 23, 2013 05:45 AM|LINK
The classes are partial so you can add properties etc in your own partial class. Also to declare meta data information you can use the MetadataType attribute (for example for data annoatations) and declare the annotations in a seperate class.