The model backing the 'ApplicationDbContext' context has changed since the database was created

前端 未结 21 1358
情话喂你
情话喂你 2020-12-02 07:24

First of all, I have not seen this error anywhere else and I guess it\'s not a replicate so please read the whole situation first.

Everything was working just fine

相关标签:
21条回答
  • 2020-12-02 07:35

    Just in case anyone else stumbles upon this that was doing a database first implementation like me.

    I made a change by extending the ApplicationUser class, adding a new field to the AspNetUsers table, and then had this error on startup.

    I was able to resolve this by deleting the record created in the __MigrationHistory table (there was only one record there) I assume EF decided that I needed to update my database using the migration tool - but I had already done this manually myself.

    0 讨论(0)
  • 2020-12-02 07:35

    Deleting Rows in [__MigrationHistory] table with Older productVersion worked for me. This answer is for those who don't want to delete entire [__MigrationHistory] table. Just delete the rows with older version in ProductVersion Column. Hope it helps some one!

    0 讨论(0)
  • 2020-12-02 07:35

    Below was the similar kind of error i encountered

    The model backing the 'PsnlContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).

    I added the below section in the Application Start event of the Global.asax to solve the error

    Database.SetInitializer (null);

    This fixed the issue

    0 讨论(0)
  • 2020-12-02 07:36

    If you delete the "[__MigrationHistory]" table from your "database > System Tables" then it will work.

    0 讨论(0)
  • 2020-12-02 07:37

    I just solved a similar problem by deleting all files in the website folder and then republished it.

    0 讨论(0)
  • 2020-12-02 07:37

    Delete existing db ,create new db with same name , copy all data...it will work

    0 讨论(0)
提交回复
热议问题