[Topic 1]
When we run the application in second time with class change in Visual Studio, we will encounter an error saying that database has been changed.
There are four strategies in IDatabaseInitializer
Database.SetInitializer()
Actually, we can put the code in Application_Start() method of Global.asax file.
We have to change the Configuration class to become public since we use it in different project above.
[Topic 2]
When removing a field in class, we sometimes encounter following error message:
Automatic migration was not applied because it would result in data loss.
We can then add AutomaticMigrationDataLossAllowed = true in Configuration.cs file
[Topic 3]
Avoid Seed method to run everytime when we run the application. There are couple workaround ways to avoid it, but none of it are perfect.
1. Disalbe DatabaseInitializer by comment out Database.SetInitializer
2. Using complier #if & #endif directive, it will compile the code between the directives only if true or the specified symbol is defined
沒有留言:
張貼留言