question

melonNG-6986 avatar image
0 Votes"
melonNG-6986 asked Bruce-SqlWork answered

Problems about upgrade .net5 to .net6 RC

I have a site only for the reading database from MySQL.

Now I am about to upgrade it from .net 5 to .net6 RC.

The site has installed
Microsoft.EntityFrameworkCore
Microsoft.EntityFrameworkCore.Abstraction
Microsoft.EntityFrameworkCore.Relational
6.0.0-rc.1.21452.10 version
and
Pomelo.EntityFrameworkCore.MySql
6.0.0-preview.5 version
nuget package.

And here is the code of database:
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;

 namespace SIComponent.Database
 {
     public class SIContext : DbContext
     {
         public virtual DbSet<TopicsModel> Topics { get; set; }
            
         public virtual DbSet<topic_pool_Model> topic_pool { get; set; }
        
         [Table("topic_pool")]
         public class topic_pool_Model : SIComponent.Database.TopicArticleModel
         {
         }
         public SIContext(DbContextOptions<SIContext> options) : base(options)
         {
    
         }
          
     }
 }

After the website ran, visual studio reports an error at:
public SIContext(DbContextOptions<SIContext> options) : base(options)

Here is the detail of the error:
System.TypeLoadException
HResult=0x80131522
Message=Method 'AppendIdentityWhereCondition' in type 'Pomelo.EntityFrameworkCore.MySql.Update.Internal.MySqlUpdateSqlGenerator' from assembly 'Pomelo.EntityFrameworkCore.MySql, Version=6.0.0.0, Culture=neutral, PublicKeyToken=2cc498582444921b' does not have an implementation.
Source=Pomelo.EntityFrameworkCore.MySql
StackTrace:
at Microsoft.Extensions.DependencyInjection.MySqlServiceCollectionExtensions.AddEntityFrameworkMySql(IServiceCollection serviceCollection)
at Pomelo.EntityFrameworkCore.MySql.Infrastructure.Internal.MySqlOptionsExtension.ApplyServices(IServiceCollection services)
at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.ApplyServices(IDbContextOptions options, ServiceCollection services)
at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.<GetOrAdd>g_BuildServiceProvider|4_0(IDbContextOptions options, ConcurrentDictionary`2 configurations)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd[TArg](TKey key, Func`3 valueFactory, TArg factoryArgument)
at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.GetOrAdd(IDbContextOptions options, Boolean providerRequired)
at Microsoft.EntityFrameworkCore.DbContext..ctor(DbContextOptions options)
at SIComponent.Database.SIContext..ctor(DbContextOptions`1 options) in E:\Project\Test\SIComponent\Database\SIContext.cs:line 30
at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
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 callSite, 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
DisplayClass2_0.<RealizeService>b0(ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, Boolean isDefaultParameterRequired)
at Microsoft.AspNetCore.Mvc.Controllers.ControllerActivatorProvider.<>c
DisplayClass7_0.<CreateActivator>b0(ControllerContext controllerContext)
at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c
DisplayClass6_0.<CreateControllerFactory>g_CreateController|0(ControllerContext controllerContext)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()


What's wrong with my code? And how can I solve this? Thank you.

dotnet-aspnet-core-generaldotnet-entity-framework-core
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered

Looks like an issue with Pomelo.EntityFrameworkCore.MySql. Maybe configuration. Check their issues.


https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.