C# 添加迁移错误:指定的架构无效
我无法创建新迁移C# 添加迁移错误:指定的架构无效,c#,entity-framework,ef-code-first,entity-framework-migrations,ef-fluent-api,C#,Entity Framework,Ef Code First,Entity Framework Migrations,Ef Fluent Api,我无法创建新迁移添加迁移测试 软件包版本 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
添加迁移测试
软件包版本
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架构验证失败。模式错误
资料:
''
属性未声明。。(0,0):错误2025:XML
映射架构的架构验证失败。架构错误信息
字体
''
属性未声明。。(0,0):错误2025:XML
映射架构的架构验证失败。架构错误信息
字体
''
属性未声明。。(0,0):错误2025:XML
映射架构的架构验证失败。架构错误信息
字体
''
属性未声明。。(0,0):错误2025:XML
映射架构的架构验证失败。架构错误信息
字体
''
属性未声明。。(0,0):错误2025:XML
映射架构的架构验证失败。架构错误信息
字体
''
属性未声明。。(0,0):错误2025:XML
映射架构的架构验证失败。架构错误信息
字体
''
属性未声明。。在
System.Data.Entity.Core.Mapping.StorageMappingItemCollection.Init(EdmItemCollection
edmCollection、StoreItemCollection、storeCollection、IEnumerable1
xmlReaders,IList
1文件路径,布尔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.EdmModelDifference.Diff(XDocument
sourceModel,XDocument targetModel,ModificationCommandTreeGenerator
modificationCommandTreeGenerator、MigrationSqlGenerator
migrationSqlGenerator)位于
System.Data.Entity.Migrations.DbMigrator.Scaffold(字符串
migrationName、字符串命名空间、布尔值ignoreChanges)位于
System.Data.Entity.Migrations.Design.MigrationScaffolder.Scaffold(字符串
migrationName,布尔值ignoreChanges)位于
System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.Scaffold(迁移文件夹
架子工)
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、字符串语言、字符串根命名空间、布尔值
忽略(变化)在
System.Data.Entity.Migrations.AddMigrationCommand.Execute(字符串名称,
布尔力,布尔信号变化)在
System.Data.Entity.Migrations.AddMigrationCommand.c_DisplayClass2.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 Entidade:EntityNome,IAuditavel
{
公共日期时间CriadoAs{get;set;}
公共虚拟Usuario CriadoPor{get;set;}
公共日期时间?AtualizadoAs{get;set;}
公共虚拟Usuario AtualizadoPor{get;set;}
}
公共类商场:Entidade
{
公共字符串{get;set;}
公共字符串CNPJ{get;set;}
公共字符串InscricaoEstadual{get;set;}
公共字符串网站{get;set;}
公共虚拟ICollection表示符{get;set;}
公共虚拟主机{get;set;}
公共虚拟ICollection电视{get;set;}
公共虚拟ICollection Enderecos{get;set;}
公共虚拟ICollection电子邮件{get;set;}
}
公共类机构:Empresa
{
公共字符串{get;set;}
公共虚拟区域{get;set;}
公共虚拟ICollection Gerentes{get;set;}
}
公共类区域:EntityNome
{
公共虚拟ICollection Contatos{get;set;}
}
配置
public类EntidadeConfiguracao:EntityTypeConfiguration
{
公共实体经济图形库()
{
属性(p=>p.Nome).IsName(true);
HasRequired(p=>p.CriadoPor).WithMany().WillCascadeOnDelete(false);
ToTable(“实体”);
}
}
公共类配置:EntityTypeConfiguration
{
公营商场
{
HasMany(p=>p.telefone)。WithMany().Map(m=>m.ToTable(“EmpresaTelefones”);
HasMany(p=>p.email).WithMany().Map(m=>m.ToTable(“EmpresaEmails”);
HasMany(p=>p.Enderecos).WithMany().Map(m=>m.ToTable(“empresenderecos”);
HasMany(p=>p.Representantes);
ToTable(“Empresas”);
}
}
公共类代理配置:EntityTypeConfiguration您需要重新创建迁移。看一看“你需要知道的事情”一节
以下是EF codeplex网站上的相关信息
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");
}
}