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

前端 未结 21 1426
情话喂你
情话喂你 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:34

    I was having same problem as a7madx7, but with stable release of EF (v6.1.1), and found resolution posted in:

    http://cybarlab.com/context-has-changed-since-the-database-was-created

    with variation in: http://patrickdesjardins.com/blog/the-model-backing-the-context-has-changed-since-the-database-was-created-ef4-3

    2nd link includes specific mention for VB..... "you can simply add all the databasecontext that are having this problem on your app_start method in the global.asax file like this":

    Database.SetInitializer(Of DatabaseContext)(Nothing)
    

    NB: i had to replace "DatabaseContext" with the name of my class implementing DbContext

    Update: Also, when using codefirst approach to connect to existing tables, check database to see if EF has created a table "_migrationhistory" to store mappings. I re-named this table then was able to remove SetInitializer from global.asax.

提交回复
热议问题