Entity Framework Automatic Migrations Existing Database

后端 未结 3 1465
孤独总比滥情好
孤独总比滥情好 2021-01-13 20:51

I am building an ASP.Net MVC4 web application with Entity Framework 5. I had to use an existing sql server database but also wanted to use Code First, so I followed this tut

3条回答
  •  滥情空心
    2021-01-13 21:46

    I had a similar problem.

    The cause for me was that the same migration had been run already in the database but under a different MigrationID. I had 201504302005411_InitialCreate but my migration script was called 201505041911076_InitialCreate.

    I fixed the issue by renaming the MigrationID in the database to match the one in my code.

    I don't quite know how I ended up in the situation but renaming the MigrationID meant the app knew the script had already been run.

提交回复
热议问题