【发布时间】:2022-10-25 22:12:17
【问题描述】:
Good Day Developers,
Please I updated my .Net5 to .Net6 and I have this errors on adding migration:
System.MissingMethodException:找不到方法:'System.Type Microsoft.EntityFrameworkCore.Metadata.ITypeBase.get_ClrType()'。
在 Abp.EntityFrameworkCore.AbpDbContext.OnModelCreating(ModelBuilder modelBuilder)
在 Abp.Zero.EntityFrameworkCore.AbpZeroCommonDbContext3.OnModelCreating(ModelBuilder modelBuilder) at Abp.Zero.EntityFrameworkCore.AbpZeroDbContext4.OnModelCreating(ModelBuilder modelBuilder)
在 Microsoft.EntityFrameworkCore.Infrastructure.ModelCustomizer.Customize(ModelBuilder modelBuilder,DbContext 上下文)
在 Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateModel(DbContext 上下文,IConventionSetBuilder 约定SetBuilder,ModelDependencies modelDependencies)
在 Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.GetModel(DbContext 上下文,ModelCreationDependencies modelCreationDependencies,布尔设计时间)
在 Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel(布尔设计时间)
在 Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model()
在 Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder.<>c.b__8_4(IServiceProvider p)
在 Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite,TArgument 参数)
在 Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite 构造函数CallSite,RuntimeResolverContext 上下文)
在 Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument 参数)
在 Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite,RuntimeResolverContext 上下文,ServiceProviderEngineScope serviceProviderEngine,RuntimeResolverLock lockType)
在 Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCacMicrosoft.EntityFrameworkCore.Metadata.ITypeBase.get_ClrType()'。
我检查了我所有的 microsoft.entityFrameworkcore 包,它们的版本相同。指向我的代码的这个版本,
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<BinaryObject>(b =>
{
b.HasIndex(e => new { e.TenantId });
});
modelBuilder.Entity<ChatMessage>(b =>
{
b.HasIndex(e => new { e.TenantId, e.UserId, e.ReadState });
b.HasIndex(e => new { e.TenantId, e.TargetUserId, e.ReadState });
b.HasIndex(e => new { e.TargetTenantId, e.TargetUserId, e.ReadState });
b.HasIndex(e => new { e.TargetTenantId, e.UserId, e.ReadState });
});
modelBuilder.Entity<Friendship>(b =>
{
b.HasIndex(e => new { e.TenantId, e.UserId });
b.HasIndex(e => new { e.TenantId, e.FriendUserId });
b.HasIndex(e => new { e.FriendTenantId, e.UserId });
b.HasIndex(e => new { e.FriendTenantId, e.FriendUserId });
});
modelBuilder.Entity<Tenant>(b =>
{
b.HasIndex(e => new { e.SubscriptionEndDateUtc });
b.HasIndex(e => new { e.CreationTime });
});
modelBuilder.Entity<SubscriptionPayment>(b =>
{
b.HasIndex(e => new { e.Status, e.CreationTime });
b.HasIndex(e => new { PaymentId = e.ExternalPaymentId, e.Gateway });
});
modelBuilder.Entity<SubscriptionPaymentExtensionData>(b =>
{
b.HasQueryFilter(m => !m.IsDeleted)
.HasIndex(e => new { e.SubscriptionPaymentId, e.Key, e.IsDeleted })
.IsUnique();
});
modelBuilder.Entity<UserDelegation>(b =>
{
b.HasIndex(e => new { e.TenantId, e.SourceUserId });
b.HasIndex(e => new { e.TenantId, e.TargetUserId });
});
modelBuilder.ConfigurePersistedGrantEntity();
}
有什么我可以实施来解决这个问题。请我需要帮助.
【问题讨论】:
标签: c# asp.net entity-framework-core .net-5 aspnetboilerplate