You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Exception has been thrown by the target of an invocation.
The type initializer for 'Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache' threw an exception.
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstanceT
The text was updated successfully, but these errors were encountered:
I got here via a web search as we just had the same problem. Ensure that all your NuGet package versions are up-to-date. The first install of Microsoft.EntityFrameworkCore and assorted related providers like Sqlite and PostgreSQL does surprisingly not build in a functioning state for us.
After downloading the latest versions of the NuGet packages, Visual Studio immediately wants us to update a large number of their dependencies even more. And what's more, after a first wave of updates, we have needed to close the NuGet Package Manager tab and re-open it, and even more updates are discovered as available (and actually necessary).
For us, I think the root cause of this particular one was that it needed the System.ValueTuple package (a dependency from Npgsql.EntityframeworkCore.PostgreSQL) to be no less than Version 4.5.0. You may find more information if you look into the InnerException of your exception. There's a hint in the exception in that it's one of the providers and not EF Core itself that has a problem; in our case a late-loaded assembly causing a runtime exception due to a version mismatch.
For me solving turned out to be related to installed packages, dependencies, and version redirects.
Finding information about regeneration of the redirects finally helped me to sort it out.
windows server 2008 r2
Exception has been thrown by the target of an invocation.
The type initializer for 'Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache' threw an exception.
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstanceT
The text was updated successfully, but these errors were encountered: