【问题标题】:System.Data.Entity.Core.MetadataException: Schema specified is not validSystem.Data.Entity.Core.MetadataException:指定的架构无效
【发布时间】:2018-04-10 15:21:24
【问题描述】:


我试图在我的解决方案中添加一个 db-Migration。但它退出并出现以下错误:

System.Data.Entity.Core.MetadataException: Schema specified is not valid. Errors: 
(0,0) : error 0040: The Type NVARCHAR2 is not qualified with a namespace or alias. Only primitive types can be used without qualification.
(0,0) : error 0040: The Type TIMESTAMP is not qualified with a namespace or alias. Only primitive types can be used without qualification.
(0,0) : error 0040: The Type NCLOB is not qualified with a namespace or alias. Only primitive types can be used without qualification.
... (more errors are following)

这是我的 DbMigrationsConfiguration:

using System.Data.Entity.Migrations;
using Devart.Data.Oracle.Entity.Migrations;

namespace ProductInformation.Migrations
{
    public sealed class Configuration : DbMigrationsConfiguration<ProductInformationContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = true;
            SetSqlGenerator(OracleConnectionInfo.InvariantName,
                new OracleEntityMigrationSqlGenerator());
        }

        protected override void Seed(ProductInformationContext context)
        {
        }
    }
}

还有我的 DbContext:

using System.Data.Entity;

namespace ProductInformation
{
    public sealed class ProductInformationContext : DbContext
    {
        static ProductInformationContext()
        {
            var config = Devart.Data.Oracle.Entity.Configuration.OracleEntityProviderConfig.Instance;
            config.CodeFirstOptions.RemoveSchemaFromDefaultConstraintName = true;
            config.CodeFirstOptions.TruncateLongDefaultNames = true;
            config.Workarounds.IgnoreDboSchemaName = true;
            config.DmlOptions.BatchUpdates.Enabled = true;
        }

        public ProductInformationContext()
            : base("name=ProductInformationConnectionString")
        {
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Price>().Property(p => p.Value).HasPrecision(8, 2);
        }

        // some other DbSet

        public DbSet<Price> Prices { get; set; }
    }
}

我不知道错误来自哪里以及如何解决它。 我已经尝试了 ColumnTypeCasingConventionCompatibility 设置,但它没有解决错误。

dotConnect for Oracle 9.5.454.0
英孚 6.2.0
.NET 4.6.1
甲骨文 12c

【问题讨论】:

    标签: c# entity-framework-6 ef-code-first devart


    【解决方案1】:

    您使用 Entity Developer 及其DbContext template 生成模型映射,不是吗?请设置 Fluent Mapping = True(在 DbContext 模板的属性中)和 Metadata Artifact Processing = Do Not Generate Mapping Files(在模型设置中),保存模型并重建项目。是这样的吗?

    【讨论】:

    • 我们自己编写了 DbContext,没有使用任何生成器或模板。
    • 我们会尽快调查问题并通知您结果。
    猜你喜欢
    • 2017-12-29
    • 1970-01-01
    • 2015-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多