Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not load type AdHocMapper after upgrading from 8 to 9 #35179

Open
rwb196884 opened this issue Nov 22, 2024 · 4 comments
Open

Could not load type AdHocMapper after upgrading from 8 to 9 #35179

rwb196884 opened this issue Nov 22, 2024 · 4 comments

Comments

@rwb196884
Copy link

Unit test project using in memory database (Microsoft.EntityFrameworkCore.InMemory).

Working in net8.

Updated to net9 and updated packages and now it's stopped working.

Message: 
System.TypeLoadException : Could not load type 'Microsoft.EntityFrameworkCore.Metadata.Internal.AdHocMapper' from assembly 'Microsoft.EntityFrameworkCore, Version=9.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

  Stack Trace: 
EntityFrameworkRelationalServicesBuilder.TryAddCoreServices()
SqlServerServiceCollectionExtensions.AddEntityFrameworkSqlServer(IServiceCollection serviceCollection)
SqlServerOptionsExtension.ApplyServices(IServiceCollection services)
ServiceProviderCache.ApplyServices(IDbContextOptions options, ServiceCollection services)
ServiceProviderCache.<GetOrAdd>g__BuildServiceProvider|4_1(IDbContextOptions _, ValueTuple`2 arguments)
<>c.<GetOrAdd>b__4_0(IDbContextOptions contextOptions, ValueTuple`2 tuples)
ConcurrentDictionary`2.GetOrAdd[TArg](TKey key, Func`3 valueFactory, TArg factoryArgument)
ServiceProviderCache.GetOrAdd(IDbContextOptions options, Boolean providerRequired)
DbContext.ctor(DbContextOptions options)
XxxDbContext.ctor(DbContextOptions`1 options) line 64
<26 more frames...>
DelegatedWebApplicationFactory.CreateHost(IHostBuilder builder)
WebApplicationFactory`1.ConfigureHostBuilder(IHostBuilder hostBuilder)
WebApplicationFactory`1.EnsureServer()
WebApplicationFactory`1.CreateDefaultClient(DelegatingHandler[] handlers)
WebApplicationFactory`1.CreateDefaultClient(Uri baseAddress, DelegatingHandler[] handlers)
WebApplicationFactory`1.CreateClient(WebApplicationFactoryClientOptions options)
TestBase.ctor(XxxWebApplicationFactory`1 factory, Boolean passTroughSecurity) line 54
SomeTests.ctor(XxxWebApplicationFactory`1 factory) line 13
InvokeStub_SomeTests.ctor(Object, Span`1)
MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
@ajcvickers
Copy link
Member

This issue is lacking enough information for us to be able to fully understand what is happening. Please attach a small, runnable project or post a small, runnable code listing that reproduces what you are seeing so that we can investigate.

@lucasdelsilva
Copy link

lucasdelsilva commented Nov 24, 2024

Bro, I had the same problem with versions, I was having this same error after the update, unfortunately version 9 is still in preview "Basically", so the most advisable thing is to go back to version 8.11 and continue until they fix this error...

In my case it was this...

Before with the Error (V9):

<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" />

After without the error (V8.11):

<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.11" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" />

@SimonCropp
Copy link
Contributor

My assumption is that Pomelo.EntityFrameworkCore.MySql is using an internal API of EF, and needs to be updated to EF V9

Probs better to close this and add a comment this this thread PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#1841

@rwb196884
Copy link
Author

I do not use MySQL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants