When creating controllers make sure change data context class to use DB name
Ex.
change:
ApplicationDbContext (WebMSWReg.Models)
to
WebMSWRegDB(WebMSWReg.Models)
DATA MIGRATIONS
http://azure.microsoft.com/en-us/documentation/articles/web-sites-dotnet-deploy-aspnet-mvc-app-membership-oauth-sql-database/
http://www.shujaat.net/2012/03/entity-framework-code-first-connection.html
In the Package Manager Console hit the up arrow key to bring up the following command:
Update-Database
Run the Update-Database command which will run the Seed method, and that will run the AddUserAndRole you just added. The AddUserAndRole will create the user user1@contoso.com and add her to the canEdit role.
PM> Enable-Migrations More than one context type was found in the assembly 'ProMVC5Ch4'. To enable migrations for 'ProMVC5Ch4.Models.ApplicationDbContext', use Enable-Migrations -ContextTypeName ProMVC5Ch4.Models.ApplicationDbContext. To enable migrations for 'ProMVC5Ch4.Models.ProMVC5Ch4DB', use Enable-Migrations -ContextTypeName ProMVC5Ch4.Models.ProMVC5Ch4DB. PM> Enable-Migrations -ContextTypeName ProMVC5Ch4.Models.ProMVC5Ch4DB Checking if the context targets an existing database... Code First Migrations enabled for project ProMVC5Ch4. PM> Add-Migration cmdlet Add-Migration at command pipeline position 1 Supply values for the following parameters: Name: Initial Scaffolding migration 'Initial'. The Designer Code for this migration file includes a snapshot of your current Code First model. This snapshot is used to calculate the changes to your model when you scaffold the next migration. If you make additional changes to your model that you want to include in this migration, then you can re-scaffold it by running 'Add-Migration Initial' again. PM> Update-Database Specify the '-Verbose' flag to view the SQL statements being applied to the target database. Applying explicit migrations: [201410241500330_Initial]. Applying explicit migration: 201410241500330_Initial. Running Seed method. PM>
Seeding a Database
then update database
thanks for sharing wonderful article on Tech Stuffs
ReplyDeleteThe innovative data migration services provided by your company have helped me with the functional procedure of the data migration. It was a fortune for me when I had to contact your company and got satisfied with the execution of the project management requirements.
ReplyDeleteData migrationis the process of moving data from one platform to another. For those migrating data across platforms, this can become a difficult and time consuming process. That is why you’ll appreciate the data migration assistant. This handy software will help you get the job done quickly and efficiently, reducing the risk of errors and making the entire process much easier.
ReplyDelete