0

I can not create a new migration Add-Migration Testing

Package version

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

Error

When I try to create a new migration the following error occurs:

PM> Add-Migration Testing System.Data.Entity.Core.MappingException: Schema specified is not valid. Errors: (0,0) : error 2025: XML Schema validation failed for mapping schema. Schema Error Information : The 'http://schemas.microsoft.com/ado/2012/10/edm/migrations:IsSystem' attribute is not declared.. (0,0) : error 2025: XML Schema validation failed for mapping schema. Schema Error Information : The 'http://schemas.microsoft.com/ado/2012/10/edm/migrations:IsSystem' attribute is not declared.. (0,0) : error 2025: XML Schema validation failed for mapping schema. Schema Error Information : The 'http://schemas.microsoft.com/ado/2012/10/edm/migrations:IsSystem' attribute is not declared.. (0,0) : error 2025: XML Schema validation failed for mapping schema. Schema Error Information : The 'http://schemas.microsoft.com/ado/2012/10/edm/migrations:IsSystem' attribute is not declared.. (0,0) : error 2025: XML Schema validation failed for mapping schema. Schema Error Information : The 'http://schemas.microsoft.com/ado/2012/10/edm/migrations:IsSystem' attribute is not declared.. (0,0) : error 2025: XML Schema validation failed for mapping schema. Schema Error Information : The 'http://schemas.microsoft.com/ado/2012/10/edm/migrations:IsSystem' attribute is not declared.. (0,0) : error 2025: XML Schema validation failed for mapping schema. Schema Error Information : The 'http://schemas.microsoft.com/ado/2012/10/edm/migrations:IsSystem' attribute is not declared.. at System.Data.Entity.Core.Mapping.StorageMappingItemCollection.Init(EdmItemCollection edmCollection, StoreItemCollection storeCollection, IEnumerable1 xmlReaders, IList1 filePaths, Boolean throwOnError) at System.Data.Entity.Core.Mapping.StorageMappingItemCollection..ctor(EdmItemCollection edmCollection, StoreItemCollection storeCollection, IEnumerable`1 xmlReaders) at System.Data.Entity.Utilities.XDocumentExtensions.GetStorageMappingItemCollection(XDocument model, DbProviderInfo& providerInfo) at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.Diff(XDocument sourceModel, XDocument targetModel, ModificationCommandTreeGenerator modificationCommandTreeGenerator, MigrationSqlGenerator migrationSqlGenerator) at System.Data.Entity.Migrations.DbMigrator.Scaffold(String migrationName, String namespace, Boolean ignoreChanges) at System.Data.Entity.Migrations.Design.MigrationScaffolder.Scaffold(String migrationName, Boolean ignoreChanges) at System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.Scaffold(MigrationScaffolder scaffolder) at System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.Run() at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate) at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner) at System.Data.Entity.Migrations.Design.ToolingFacade.Scaffold(String migrationName, String language, String rootNamespace, Boolean ignoreChanges) at System.Data.Entity.Migrations.AddMigrationCommand.Execute(String name, Boolean force, Boolean ignoreChanges) at System.Data.Entity.Migrations.AddMigrationCommand.<>c_DisplayClass2.<.ctor>b_0() at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)

Code

The code is quite extensive. These are the last classes that have changed.

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; }
}

Configuration

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");
    }
}    

Posted on aspnetwebstack issue

abatishchev
  • 98,240
  • 88
  • 296
  • 433
ridermansb
  • 10,779
  • 24
  • 115
  • 226

1 Answers1

1

You need to recreate your migrations. Take a look at the "Things You Need to Know" section in the EF6 Beta1 announcement

Here is a related work item on the EF codeplex site.

Pawel
  • 31,342
  • 4
  • 73
  • 104