Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot register IRelationalTypeMappingSource

System.InvalidOperationException: 'The database provider attempted to register an implementation of the 'IRelationalTypeMappingSource' service. This is not a service defined by Entity Framework and as such must be registered as a provider-specific service using the 'TryAddProviderSpecificServices' method.'

This is the exception when I run page with DbContext in.

The website is Razor Pages.

Website was working well a I did not change anything a now this happened.

Here is .csproj

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.10" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.10">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.4" />
    <PackageReference Include="Microsoft.Windows.Compatibility" Version="5.0.0" />
  </ItemGroup>

</Project>

Does anyone know how to fix this issue?

like image 200
Almaran Avatar asked Dec 23 '20 10:12

Almaran


1 Answers

You are mixing versions, and referencing too many packages. change to this:

<ItemGroup>
    <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.10" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.10">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.4" />
    <PackageReference Include="Microsoft.Windows.Compatibility" Version="3.1.1" />
  </ItemGroup>
like image 148
ErikEJ Avatar answered Sep 18 '22 03:09

ErikEJ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!