0

I'm using Red Gate SQL Compare to upgrade my database without losing data. I also use ASP.NET MVC with Entity Framework and SQL Server.

Problem is that Visual Studio still detects model modification although I've already updated the database with Red Gate SQL Compare. When I try to run add-migration in Visual Studio and then update-database, it crashes saying that the fields already exists.

Thanks for any help.

Erik Philips
  • 53,428
  • 11
  • 128
  • 150
Prince Gnakou
  • 87
  • 1
  • 3
  • 12
  • Why are you not upgrading your database using a migration? – Caius Jard Dec 22 '17 at 17:19
  • The migrations table is still based on the old model. EF compares it to a checksum of the new model. So: if you routinely want to upgrade the database manually, switch off migrations. – Gert Arnold Dec 22 '17 at 20:45
  • I cannot use migrations because the database is on a production server without visual studio installed. And i actually did switch off the migrations (By deleting the migrations folder right?). – Prince Gnakou Dec 23 '17 at 11:03

1 Answers1

1

You may delete generated migration that is crashing, then run Add-Migration command once again, but with -IgnoreChanges flag. It will generate empty migration that will effectively do nothing except adding new entry into migration table with current model info. This should help you go on with your explicit db update.

dropoutcoder
  • 2,627
  • 2
  • 14
  • 32