I tinkered around with Data Migrations in MVC 4.0 and I have to say, It's really convenient.
Make sure connection string is updated to the desired database
In NuGet package manager console
Note that some files are added to the Migrations folder
Make sure connection string is updated to the desired database
In NuGet package manager console
PM> Enable-Migrations -ContextTypeName Class1
- Class1 derives from DbContext
- -ContextTypeName is only needed if more than one class derives from DbContext
Note that some files are added to the Migrations folder
- configuration.cs
- Set AutomaticMigrationsEnabled = true to update database for development
- Seed(...) is used to update the database
- migration.cs
- The seed(...) method in Configuration is ran everytime update-database command is issued
PM> update-database
No comments:
Post a Comment