Mic*_*ges 66 entity entity-framework ef-migrations
我试图忽略使用Entity Framework 6.0 rc1的"自动"迁移.我的问题是我现在不想要这个功能,每次运行我的应用程序时,我都可以看到所有实体日志都试图创建所有表.
期待感谢.
Car*_*ira 47
您可以将它放在app.config的entityFramework部分中:
<contexts>
<context type="YourNamespace.YourDbContext, YourAssemblyName" disableDatabaseInitialization="true"/>
</contexts>
Run Code Online (Sandbox Code Playgroud)
这个msdn页面告诉所有关于实体框架配置部分.
Sey*_*baf 46
试试这个:
internal sealed class Configuration : DbMigrationsConfiguration<YourContext>
{
public Configuration()
{
AutomaticMigrationsEnabled = false;
}
}
Run Code Online (Sandbox Code Playgroud)
更新:
你也可以试试这个:
Database.SetInitializer<YourContextType>(new CreateDatabaseIfNotExists());
Run Code Online (Sandbox Code Playgroud)
Aar*_*man 27
通过web.config参见 - https://msdn.microsoft.com/en-us/data/jj556606.aspx#Initializers
通过代码(奇怪的是,MUCH答案更简单)
public class MyDB : DbContext
{
public MyDB()
{
Database.SetInitializer<MyDB>(null);
}
}
Run Code Online (Sandbox Code Playgroud)
或者在Global.asax.cs中
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
// ...
Database.SetInitializer<MyDB>(null);
/// ...
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
66642 次 |
| 最近记录: |