How can I disable code first migrations

后端 未结 5 1644
醉话见心
醉话见心 2020-11-30 23:05

I have a code-first entity model in EF5. But I want to manage the database changes manually -- I do not want EF to modify my existing database and all its data. But when I m

5条回答
  •  执念已碎
    2020-11-30 23:41

    So the most complete answer that I have found is this:

    1. Delete Migrations folder inside your project.
    2. Set Database.SetInitializer(null); inside your DatabaseContext initializer.
    3. Delete the table __MigrationHistory inside your database. For EF6+ the table is located under Tables but for earlier versions it is located under System Tables.
    4. Build and run.
    5. Profit.

提交回复
热议问题