Whenever there are any changes in table column the whole file generated by entity framework replaces all the code with auto generated one. Now I'm using partial class to avoid this problem, But now I have come across a situation where some list has to be initialized in constructor since there are no partial constructor this is not possible, Please suggest any work around to avoid code replace or to do it in a better way.
Asked
Active
Viewed 41 times
-1
-
See this http://stackoverflow.com/questions/14485052/ef-5-model-first-partial-class-custom-constructor-how-to – Steve Greene Dec 10 '16 at 22:29
-
Are you able to switch to EF's code first approach? No more auto-generated files... – colinsmith1 Dec 17 '16 at 21:52
1 Answers
0
Not really shure about that, but as i know you can use partial method OnCreate
:
public partial class Entity1
{
partial void OnCreated()
{
//modify your entity here
}
}
It will fire when new entity is created

layonez
- 1,746
- 1
- 16
- 20