0

我无法创建新的迁移Add-Migration Testing

包版本

Microsoft.AspNet.WebApi -> 5.0.0-beta1-130515
Microsoft.AspNet.WebApi.Client -> 5.0.0-beta1-130515
Microsoft.AspNet.WebApi.Core -> 5.0.0-beta1-130515
Microsoft.AspNet。 WebApi.OData -> 5.0.0-beta1-130515
Microsoft.AspNet.WebApi.Web... -> 5.0.0-beta1-130515

错误

当我尝试创建新迁移时,会发生以下错误:

PM> 添加迁移测试 System.Data.Entity.Core.MappingException:指定的架构无效。错误:(0,0):错误 2025:映射架构的 XML 架构验证失败。架构错误信息:未声明“ http://schemas.microsoft.com/ado/2012/10/edm/migrations:IsSystem ”属性。(0,0):错误 2025:映射架构的 XML 架构验证失败. 架构错误信息:未声明“ http://schemas.microsoft.com/ado/2012/10/edm/migrations:IsSystem ”属性。(0,0):错误 2025:映射架构的 XML 架构验证失败. 架构错误信息:' http: //schemas.microsoft.com/ado/2012/10/edm/migrations :IsSystem' 属性未声明.. (0,0):错误 2025:映射架构的 XML 架构验证失败。架构错误信息:未声明“ http://schemas.microsoft.com/ado/2012/10/edm/migrations:IsSystem ”属性。(0,0):错误 2025:映射架构的 XML 架构验证失败. 架构错误信息:未声明“ http://schemas.microsoft.com/ado/2012/10/edm/migrations:IsSystem ”属性。(0,0):错误 2025:映射架构的 XML 架构验证失败. 架构错误信息:未声明“ http://schemas.microsoft.com/ado/2012/10/edm/migrations:IsSystem ”属性。(0,0):错误 2025:映射架构的 XML 架构验证失败. 架构错误信息:'http://schemas.microsoft.com/ado/2012/10/edm/migrations:IsSystem '属性未声明..在 System.Data.Entity.Core.Mapping.StorageMappingItemCollection.Init(EdmItemCollection edmCollection, StoreItemCollection storeCollection, IEnumerable1 xmlReaders, IListSystem.Data.Entity.Utilities.XDocumentExtensions.GetStorageMappingItemCollection(XDocument 模型,DbProviderInfo& providerInfo) 在 System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.Diff(XDocument sourceModel, XDocument targetModel, ModificationCommandTreeGenerator modifyCommandTreeGenerator, MigrationSqlGenerator migrationSqlGenerator) 在 System.Data.Entity.Migrations.DbMigrator.Scaffold(String migrationName, String namespace, Boolean ignoreChanges ) 在 System.Data.Entity 的 System.Data.Entity.Migrations.Design.MigrationScaffolder.Scaffold(String migrationName, Boolean ignoreChanges)。System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.Run() 在 System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate) 在 System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate) 的 Migrations.Design.ToolingFacade.ScaffoldRunner.Scaffold(MigrationScaffolder 脚手架) )
在 System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner) 在 System.Data.Entity.Migrations.Design.ToolingFacade.Scaffold(String migrationName, String language, String rootNamespace, Boolean ignoreChanges) 在 System.Data。 Entity.Migrations.AddMigrationCommand.Execute(String name, Boolean force, Boolean ignoreChanges) 在 System.Data.Entity.Migrations.AddMigrationCommand.<>c_ DisplayClass2.<.ctor>b _0() 在 System.Data.Entity.Migrations。 MigrationsDomainCommand.Execute(操作命令)

代码

代码相当广泛。这些是最后改变的类。

public class Entidade : EntityNome, IAuditavel
{
    public DateTime CriadoAs { get; set; }
    public virtual Usuario CriadoPor { get; set; }
    public DateTime? AtualizadoAs { get; set; }
    public virtual Usuario AtualizadoPor { get; set; }
}

public class Empresa : Entidade
{
    public string RazaoSocial { get; set; }
    public string CNPJ { get; set; }
    public string InscricaoEstadual { get; set; }
    public string WebSite { get; set; } 

    public virtual ICollection<Pessoa> Representantes { get; set; }
    public virtual Pessoa Contato { get; set; }

    public virtual ICollection<Telefone> Telefones { get; set; }
    public virtual ICollection<Endereco> Enderecos { get; set; }
    public virtual ICollection<Email> Emails { get; set; }
}   

public class Agencia : Empresa
{
    public string Identificacao { get; set; }
    public virtual Regional Regional { get; set; }
    public virtual ICollection<Pessoa> Gerentes { get; set; }
}   

public class Regional : EntityNome
{
    public virtual ICollection<Pessoa> Contatos { get; set; }
}

配置

public class EntidadeConfiguracao : EntityTypeConfiguration<Entidade>
{
    public EntidadeConfiguracao()
    {
        Property(p => p.Nome).IsName(true);
        HasRequired(p => p.CriadoPor).WithMany().WillCascadeOnDelete(false);

        ToTable("Entidades");
    }
}

public class EmpresaConfiguracao : EntityTypeConfiguration<Empresa>
{
    public EmpresaConfiguracao()
    {
        HasMany(p => p.Telefones).WithMany().Map(m => m.ToTable("EmpresaTelefones"));
        HasMany(p => p.Emails).WithMany().Map(m => m.ToTable("EmpresaEmails"));
        HasMany(p => p.Enderecos).WithMany().Map(m => m.ToTable("EmpresaEnderecos"));
        HasMany(p => p.Representantes).WithMany().Map(m => m.ToTable("EmpresaRepresentantes"));

        ToTable("Empresas");
    }
}

public class AgenciaConfiguracao : EntityTypeConfiguration<Agencia>
{
    public AgenciaConfiguracao()
    {
        HasRequired(p => p.Regional).WithMany().WillCascadeOnDelete(true); //.HasForeignKey(p => p.RegionalId)
        Property(p => p.Identificacao).IsRequired().HasMaxLength(10);
        HasMany(p => p.Gerentes).WithMany().Map(m => m.ToTable("AgenciaGerentes"));

        ToTable("Agencias");
    }
}

public class RegionalConfiguracao : EntityTypeConfiguration<Regional>
{
    public RegionalConfiguracao()
    {
        Property(p => p.Nome).IsName(true);
        HasMany(p => p.Contatos).WithMany().Map(m => m.ToTable("RegionalContatos"));

        ToTable("Regionais");
    }
}    

发表在aspnetwebstack 问题上

4

1 回答 1

1

您需要重新创建迁移。看看EF6 Beta1 公告中的“你需要知道的事情”部分

这是EF codeplex 站点上的相关工作项。

于 2013-06-10T22:44:42.250 回答