System.Data.Entity.Core.MetadataException:指定的架构无效

时间:2018-04-10 15:21:24

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


我尝试将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
EF 6.2.0
.NET 4.6.1
oracle 12c

1 个答案:

答案 0 :(得分:0)

您使用Entity Developer及其DbContext template生成了模型映射,不是吗?请设置Fluent Mapping = True(在DbContext模板的属性中)和元数据工件处理=不生成映射文件(在模型设置中),保存模型并重建项目。这样做有用吗?