c# - mvc publish error with automigrations -


I am having trouble publishing my MVC project.

The 'ApplicationDbContext' reference has changed after I became a "Error Model" database. Consider using Code First Migration to update the database (). ", Which was resolved with the help of Automagration

I published my project on another machine via FTP, then added some changes to the structure of the model, ran it on my computer, he Successfully launched and republished on the same machine. When I tried to run it there, there was an error - "Since the creation of the database, the application supports the'Debiccontext 'context Odl has changed. Consider using Code First Migration to update the database. "

I am using IIS7 on Windows 7.

To update the database to another DB server, you can do this:

  1. To use the new server Configure the connection string
  2. Run the update-database command from the Package Manager console, in some cases you force flag but be careful, this can delete some of your data. In addition to this command - the connection stringname parameter can help you to update it.

    This is a very bad And I do not recommend this kind of update database.

    I usually recommend setting up Initialzier for my reference I usually use MigrateDatabaseToLatestVersion And after changing your model you can The new migration must be added using the add-migration command.

    To set this up, use this command in the application start method: Database.SetInitializer & lt; ApplicationDbContext & gt; (New MigrateDatabaseToLatestVersion & lt; ApplicationDbContext & gt; ());


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -