TypeLoadException: Method 'Create' not found in type 'MySql.Data.EntityFrameworkCore.Query.Internal.MySQLSqlTranslatingExpressionVisitorFactory'
P粉502608799
P粉502608799 2023-10-22 20:34:52
0
1
585

I'm trying to add a new user to the database using the following code:

public async void SeedUsers(){
    int count=0;
    if(count>0){
        return;
    }
    else{
        string email="jujusafadinha@outlook.com.br";
        _context.Add(new User{LoginEmail=email});  
        await _context.SaveChangesAsync();  
    }
}

But it keeps giving me the following error:

System.TypeLoadException: > Method 'Create' in type 'MySql.Data.EntityFrameworkCore.Query.Internal.MySQLSqlTranslatedExpressionVisitorFactory' in assembly 'MySql.Data.EntityFrameworkCore', version=8.0.22.0, culture=medium Properties, >PublicKeyToken=c5687fc88969c44d ' is not implemented. at MySql.Data.EntityFrameworkCore.Extensions.MySQLServiceCollectionExtensions.AddEntityFrameworkMySQL(IServ>iceCollection service) at MySql.Data.EntityFrameworkCore.Infrastruct.Internal.MySQLOptionsExtension.ApplyServices(IServiceColle>ction service) at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.ApplyServices(IDbContextOptions > Options, ServiceCollection Services) at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.c__DisplayClass4_0.b__2(Int64 k) In System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.GetOrAdd(IDbContextOptions options, >Boolean providerRequired) at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider() at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependency() at Microsoft.EntityFrameworkCore.DbContext.EntryWithoutDetectChanges[TEntity](TEntity entity) at Microsoft.EntityFrameworkCore.DbContext.SetEntityState[TEntity](TEntity entity, EntityState >entityState) at Microsoft.EntityFrameworkCore.DbContext.Add[TEntity](TEntity entity) In D:devcontatinapiDataSeedData.cs at contatinApi.Data.SeedData.SeedUsers(): line 24 at System.Threading.Tasks.Task.<>c.b__139_1(ObjectState) at System.Threading.QueueUserWorkItemCallback.<>c.<.cctor>b__6_0(QueueUserWorkItemCallback quwi) at System.Threading.ExecutionContext.RunForThreadPoolUnsafe[TState](ExecutionContext >executionContext, Action`1 callback, TState& state) in System.Threading.QueueUserWorkItemCallback.Execute() in System.Threading.ThreadPoolWorkQueue.Dispatch() In System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

User class:

public class User
    {
        public int Id{get;set;}
        public string LoginEmail{get;set;}
        public string UserName{get;set;}
        public DateTime CreatedAt{get;set;}
        public List<Contact> Contacts {get;set;}
        public List<ContactList> ContactLists{get;set;}
    }

EF Core and MySQL packages have been updated. Also, I tried using a stored procedure and it gave the same result.

The content of

Ex is:

Ex value is {System.TypeLoadException: Method 'Create' in type 'MySql.Data.EntityFrameworkCore.Query.Internal.MySQLSqlTranslatedExpressionVisitorFactory' in assembly 'MySql.Data.EntityFrameworkCore', version=8.0.22.0, culture =neutral, PublicKeyToken=c5687fc88969c44d' is not implemented. at MySql.Data.EntityFrameworkCore.Extensions.MySQLServiceCollectionExtensions.AddEntityFrameworkMySQL(IServiceCollection service) at MySql.Data.EntityFrameworkCore.Infrastruct.Internal.MySQLOptionsExtension.ApplyServices(IServiceCollection service) at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.ApplyServices(IDbContextOptions options, ServiceCollection service) at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.<>c__DisplayClass4_0.g__BuildServiceProvider|3() at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.<>c__DisplayClass4_0.b__2(Int64 k) In System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.GetOrAdd(IDbContextOptions options, Boolean providerRequired) at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider() at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependency() at Microsoft.EntityFrameworkCore.DbContext.Microsoft.EntityFrameworkCore.Internal.IDbContextDependency.get_StateManager() at Microsoft.EntityFrameworkCore.Internal.InternalDbSet1.EntryWithoutDetectChanges(TEntity entity) at Microsoft.EntityFrameworkCore.Internal.InternalDbSet1.Add(TEntity entity) In D:devContatinApiDataSeedData.cs at contatinApi.Data.SeedData.SeedUsers(): line 40}


P粉502608799
P粉502608799

reply all(1)
P粉578680675

If you are using Microsoft.EntityFrameworkCore 5.0, please downgrade it to Microsoft.EntityFrameworkCore 3.1.10 MySQL EF 8.0.22 is currently incompatible with Microsoft.EntityFrameworkCore 5.0

I had a working code until I upgraded to Microsoft.EntityFrameworkCore 5.0, then I got the same error, downgraded and it worked!

Hope to post a bug report on the MySQL Bug Forum

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template