Question

I created using aspnet_regsql all the membership tables in my database. however it looks like my initializar is removing the membership tables also

Is it possible that it removes only the tables that belong to the model??

I suppose its because of this line:

public class HRContextInitializer : DropCreateDatabaseAlways<HRContext>
    {
Was it helpful?

Solution

Yes thats right. You choose the "DropCreateDatabaseAlways" initialization strategy. You can change to "DropCreateDatabaseIfModelChanges".

If your model change, EntityFramework try to delete and rebuild the database. Please have a look at EntityFrameork.Migrations to migrate changes without rebuilding the whole database.

Scott Hanselman demos this cool new feature at his blog.

http://www.hanselman.com/blog/EntityFrameworkCodeFirstMigrationsAlphaNuGetPackageOfTheWeek10.aspx

And Scott Guthries Blog Post about EntityFramework CodeFirst

http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top