CTEC2402: Sofware Development Project

MVC5 Database Migrations

In the code first approach the database is created automatically from the fefined classes in the Models folder, this includes the membership database used to store user names and passwords. However when the models changes it is necessary to change the database to match

In MVC5 this is achieved by enabling database migrations. Open the Package Manager Console window using the Tools menu. Enter "enable-migrations" at the PM> command prompt. This will create a Migrations folder with a Configuration.cs class

Configuration.cs

In this class migrations can be enabled automatically, and bye altering the seed method users and roles can be automatically added to the newly created database after alterations. The database cab be manually updated by entering the command "update-database" at the PM> command prompt in the Package Manage Console window.

Db Seeding