【发布时间】:2013-05-11 05:55:58
【问题描述】:
我无法创建新的迁移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' 属性未声明.. at System.Data.Entity.Core.Mapping.StorageMappingItemCollection.Init(EdmItemCollection edmCollection,StoreItemCollection storeCollection,IEnumerable
1 xmlReaders, IList1 filePaths,布尔 throwOnError)在 System.Data.Entity.Core.Mapping.StorageMappingItemCollection..ctor(EdmItemCollection edmCollection,StoreItemCollection storeCollection,IEnumerable`1 xmlReaders) 在 System.Data.Entity.Utilities.XDocumentExtensions.GetStorageMappingItemCollection(XDocument 模型,DbProviderInfo 和 providerInfo)在 System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.Diff(XDocument sourceModel, XDocument targetModel, ModificationCommandTreeGenerator 修改CommandTreeGenerator、MigrationSqlGenerator 迁移SqlGenerator)在 System.Data.Entity.Migrations.DbMigrator.Scaffold(字符串 迁移名称,字符串命名空间,布尔型 ignoreChanges)在 System.Data.Entity.Migrations.Design.MigrationScaffolder.Scaffold(字符串 迁移名称,布尔型 ignoreChanges)在 System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.Scaffold(MigrationScaffolder 脚手架)在 System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.Run() 在 System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate) 在 System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
在 System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner 亚军)在 System.Data.Entity.Migrations.Design.ToolingFacade.Scaffold(字符串 migrationName, String language, String rootNamespace, Boolean 忽略更改)在 System.Data.Entity.Migrations.AddMigrationCommand.Execute(字符串名称, 布尔力,布尔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");
}
}
【问题讨论】:
标签: c# entity-framework ef-code-first entity-framework-migrations ef-fluent-api