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 make parallel changes in the EF mapping and in the database, EF refuses to operate properly telling me I need to use code first migration. How do I turn this off?
相关问题
- Entity Framework Code First Migration
- Entity Framework throws exception - Network Relate
- How to Specify a Compound key in Entity Framework
- Slow loading first page - ASP.NET MVC
- query and create objects with a one to many relati
相关文章
- 关于使用EF Core 提示错误:列名AccountID1无效的问题
-
EF6 DbSet
returns null in Moq - Entity Framework 4.3.1 failing to create (/open) a
- EF6 code first: How to load DbCompiledModel from E
- Why do I need a ToList() to avoid disposed context
- Code-First Add-Migration keeps adding the same col
- EF Codefirst validate unique property?
- EF Core 'another instance is already being tra
If you already used Migrations then changing only Initializer won't help. You need to go to Management Studio, open your database tables, go to
System Tables
folder and remove__MigrationHistory
table that is located there (for EF6 and above, it's located directly underTables
). This will disable Migrations for good.So the most complete answer that I have found is this:
Migrations
folder inside your project.Database.SetInitializer<DatabaseContext>(null);
inside your DatabaseContext initializer.__MigrationHistory
inside your database. For EF6+ the table is located underTables
but for earlier versions it is located underSystem Tables
.If you want to completely turn off migrations:
https://stackoverflow.com/a/9709407/141172
However, I found it better to keep code first migrations enabled, but use the
-Script
option to have EF create a DB change script for me that I can apply to each database (development, QA, Production) manually:That way EF will create the change script for me, and I still have full control over changes being applied. I version the change scripts like any other source code.
set the Database.SetInitializer to null.
I just resolved this "issue" by
My envirment is