I have a .NET console project targeting .NET Framework 4.7.2.
It uses Microsoft EntityFrameworkCore 3.1.2 and Microsoft.AspNetCore.Identity.EntityFrameworkCore 2.2.0 it fails at runtime with the following error :
System.MissingMethodException
HResult=0x80131513
Message=Méthode introuvable : 'Microsoft.EntityFrameworkCore.Metadata.Builders.IndexBuilder Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder`1.HasIndex(System.Linq.Expressions.Expression`1<System.Func`2<System.__Canon,System.Object>>)'.
Source=Microsoft.AspNetCore.Identity.EntityFrameworkCore
StackTrace:
at Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserContext`5.<>c__DisplayClass20_0.<OnModelCreating>b__0(EntityTypeBuilder`1 b)
at Microsoft.EntityFrameworkCore.ModelBuilder.Entity[TEntity](Action`1 buildAction)
at Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserContext`5.OnModelCreating(ModelBuilder builder)
at Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityDbContext`8.OnModelCreating(ModelBuilder builder)
at RTE.Technologies.SafeProtect.Common.Data.DbContext.Core.IdentityDbContext.OnModelCreating(ModelBuilder modelBuilder) in D:\AzureDevops\SafeProtect.Common\SafeProtect.Common.Data\DbContext\Core\IdentityDbContext.cs:line 224
at Microsoft.EntityFrameworkCore.Infrastructure.ModelCustomizer.Customize(ModelBuilder modelBuilder, DbContext context)
at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateModel(DbContext context, IConventionSetBuilder conventionSetBuilder)
at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.GetModel(DbContext context, IConventionSetBuilder conventionSetBuilder)
at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel()
at Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model()
at Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder.<>c.<TryAddCoreServices>b__7_3(IServiceProvider p)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.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 singletonCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.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 singletonCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider()
at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
at Microsoft.EntityFrameworkCore.DbContext.Set[TEntity]()
at RTE.Technologies.SafeProtect.Common.Data.DbContext.Core.IdentityDbContext.RTE.Technologies.Common.EFCoreData.Interfaces.IDbContext<RTE.Technologies.SafeProtect.Common.Data.BusinessObjects.Models.WebAdminUser>.get_DbSet() in D:\AzureDevops\SafeProtect.Common\SafeProtect.Common.Data\DbContext\Core\IdentityDbContext.cs:line 156
at RTE.Technologies.Common.EFCoreData.Repositories.Repository`1..ctor(IDbContext`1 context)
at RTE.Technologies.Common.EFCoreData.Repositories.DisableableWithDateTimeRepository`1..ctor(IDbContext`1 context)
at RTE.Technologies.SafeProtect.Common.Data.DbContext.Core.IdentityDbContext.get_WebAdminUserRepository() in D:\AzureDevops\SafeProtect.Common\SafeProtect.Common.Data\DbContext\Core\IdentityDbContext.cs:line 127
at RTE.Technologies.SafeProtect.Common.Data.DataBridge.Core.IdentityDataBridge.GetAllUsersAdminEmailByCompanyId(Int32 companyId) in D:\AzureDevops\SafeProtect.Common\SafeProtect.Common.Data\DataBridge\Core\IdentityDataBridge.WebAdminUser.cs:line 69
at RTE.Technologies.SafeProtect.Common.DummyConsole.Program.Main(String[] args) in D:\AzureDevops\SafeProtect.Common\SafeProtect.Common.DummyConsole\Program.cs:line 45
I would say that I should upgrade Microsoft.AspNetCore.Identity.EntityFrameworkCore to version 3.1.2 but I can't:
Could not install package 'Microsoft.AspNetCore.Identity.EntityFrameworkCore 3.1.2'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.7.2', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
What are my options here are as I'm stuck with EF Core 3.1.2 that should be used in several projects targeting both .NET Core 3.0 and .NET Framework 4.7.2.
You cannot mix 3.x and 2.x dependencies
User contributions licensed under CC BY-SA 3.0