简体   繁体   中英

Code-first migration error

I built my MVC C# based project using code first on local SQL Server and it all worked perfectly fine. I decided to copy my intire project to a DOK and then paste it on my other computer - I literally did copy to the DOK and paste from the DOK to the other computer desktop.

Then I ran the project and got the followind exception when I try to access one of the models using LINQ:

The model backing the 'BookStoreModel' context has changed since the database was created. Consider using Code First Migrations to update the database

I tried doing update-database -force yet I got there another error:

Cannot find the object "dbo.Customers" because it does not exist or you do not have permissions.

How can it be? The project is running perfectly fine on the original developing machine.

1) Delete All the migrations inside of the 'Migrations' folder

2) Delete all the tables in the database or delete database and recreate

3) Now goto package manager console and create new migration using Add-Migration

4) Then update database using Update-Database command

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM