How to use the Abp.ZeroCore.EntityFramework with a ASP.NET Core solution
我试图在香草ASP.NET Boilerplate模板项目中使用软件包
该模板包括Entity Framework Core,但是我想使用Entity Framework 6,因为它更加可靠并且具有Entity Framework Core缺少的功能。
为了构建它,我用
项目成功构建,没有任何警告,但是当我尝试创建迁移时,出现以下模型验证错误:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | PM> Add-Migration InitialMigration System.InvalidOperationException: The index with name 'IX_UserId_State_CreationTime' on table 'dbo.AbpUserNotifications' has the same column order of '1' specified for columns 'TenantId' and 'UserId'. Make sure a different order value is used for the IndexAttribute on each column of a multi-column index. at System.Data.Entity.Infrastructure.ConsolidatedIndex.Add(String columnName, IndexAttribute index) at System.Data.Entity.Infrastructure.ConsolidatedIndex.BuildIndexes(String tableName, IEnumerable`1 columns) at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.<FindTargetIndexes>b__278(EntitySet es) at System.Linq.Enumerable.<SelectManyIterator>d__22`3.MoveNext() at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.Diff(ModelMetadata source, ModelMetadata target, Lazy`1 modificationCommandTreeGenerator, MigrationSqlGenerator migrationSqlGenerator, String sourceModelVersion, String targetModelVersion) at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.Diff(XDocument sourceModel, XDocument targetModel, Lazy`1 modificationCommandTreeGenerator, MigrationSqlGenerator migrationSqlGenerator, String sourceModelVersion, String targetModelVersion) 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.RunCore() at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run() The index with name 'IX_UserId_State_CreationTime' on table 'dbo.AbpUserNotifications' has the same column order of '1' specified for columns 'TenantId' and 'UserId'. Make sure a different order value is used for the IndexAttribute on each column of a multi-column index. |
因此,看起来Abp.ZeroCore程序包中包含的某些模型与Abp.ZeroCore.EntityFramework程序包不兼容。
这是一个已知问题,还是有针对此错误的解决方法?
包括使用ASP.NET Core和Entity Framework 6的原始ASP.NET Boilerplate模板将非常有用。
我发现了由错误/重复的CreateIndex条目引起的错误:
1
2
3 modelBuilder.Entity<UserNotificationInfo>()
.Property(e => e.UserId)
.CreateIndex("IX_UserId_State_CreationTime", 1);
1
2
3 modelBuilder.Entity<UserNotificationInfo>()
.Property(e => e.TenantId)
.CreateIndex("IX_UserId_State_CreationTime", 1);
该修复程序将包含在下一个次要版本中。 您可以在发布ABP v3.3时对其进行升级。