'Unable to resolve service for type 'Microsoft.EntityFrameworkCore.Storage.TypeMappingSourceDependencies'
When I'm trying Add-Migration, following error was occurred.
I'm using,
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MySql.Data" Version="8.0.28" />
<PackageReference Include="MySql.EntityFrameworkCore" Version="6.0.0" />
Exception is,
PM> Add-Migration InitialCreate
Build started...
Build succeeded.
Microsoft.EntityFrameworkCore.Infrastructure[10403]
Entity Framework Core 6.0.3 initialized 'ApplicationDbContext' using provider 'MySql.EntityFrameworkCore:6.0.0+MySQL8.0.28' with options: None
System.InvalidOperationException: Unable to resolve service for type 'Microsoft.EntityFrameworkCore.Storage.TypeMappingSourceDependencies' while attempting to activate 'MySql.EntityFrameworkCore.Storage.Internal.MySQLTypeMappingSource'.
Complete error log available in this file.
Thanks in advance!
Solution 1:[1]
Oops! I forgot to update the answer. I moved from MySql.EntityFrameworkCore to Pomelo.EntityFrameworkCore.MySql.
Now I'm able to do following Add-Migration and Update-Database commands
Solution 2:[2]
You are missing the reference to Microsoft.EntityFrameworkCore
.
Try to add following reference:
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.1" />
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Naveen Nagarajan |
Solution 2 | Sebastian Siemens |