Reputation: 13367
can somebody tell me how I can add a data member (col) to my mvc3 model (class) and have it update the database without having to generate everything from scratch? I'm working from code first. When I change my model then run my project I get an error stating that model has changed. Any clean and easy way to synch creating a new col/data mamber with the db/model?
Thanks!
Upvotes: 1
Views: 3113
Reputation: 21376
you can use this in application start,
Database.SetInitializer(new DropCreateDatabaseIfModelChanges<YourDBContext>());
it will regenerate the database if your model change happens.And if you do not want to drop and create database (To incremental development) you can use SqlMigrations. http://www.hanselman.com/blog/EntityFrameworkCodeFirstMigrationsAlphaNuGetPackageOfTheWeek10.aspx
Upvotes: 2