无法禁用代码优先迁移

时间:2018-01-24 14:38:51

标签: c# entity-framework ef-code-first entity-framework-5 ef-migrations

在这里阅读许多答案,似乎为了禁用代码优先迁移,我必须只添加行Database.SetInitializer<MyContext>(null); 到我的上下文课。尽管已经这样做了,我仍然会看到如下错误。

Error OracleException: ORA-00942: table or view does not exist 
Time 717ms 
Details 
   SELECT "GROUPBY1"."A1" AS "C1" FROM ( SELECT COUNT(1) AS "A1" FROM
   "DBO"."__MIGRATIONHISTORY" "EXTENT1" ) "GROUPBY1" 

Error OracleException: ORA-00942: table or view does not exist 
Time 0ms 
Details 
    SELECT * FROM ( SELECT "PROJECT1"."C1" AS "C1", "PROJECT1"."MODELHASH" AS 
    "MODELHASH" FROM ( SELECT "EXTENT1"."MODELHASH" AS "MODELHASH", CAST( 
    "EXTENT1"."ID" AS NUMBER(10,0)) AS "C1" FROM "DBO"."EDMMETADATA" "EXTENT1" ) 
    "PROJECT1" ORDER BY "PROJECT1"."C1" DESC ) WHERE (ROWNUM <= (1) ) 

当然,根本原因是我的数据库(Oracle)不包含__MIGRATIONHISTORYMODELHASH。有一个类似的问题here表明相同的初始化,但没有额外的后续行动。

我的课程设置如下。

public class AContext : MyContext 
{
    public DbSet<> .... { get;set; }

    public override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.Configurations.Add(new Mapping());
    }
}

public class MyContext : DbContext
{
    protected MyContext() : base("name=Entities")
    {
        Database.SetInitializer<MyContext>(null);
    }
}

我还缺少什么?

0 个答案:

没有答案