Search code examples
c#asp.net-corevisual-studio-2019asp.net-mvc-scaffolding

Error running selected code generator The database provider attempted to register an implementation of 'IRelationTypeMappingSource'


I'm using Visual Studio 2019.

Before reinstalling visual studio my ASP.NET Core MVC project and scaffolder was working fine.

But after that I'm not able to add new scaffolded item.

enter image description here

enter image description here

By updating all NuGet packages and then run scaffolder it automatically degrades the packages

EDIT 1 :

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

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

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <Prefer32Bit>false</Prefer32Bit>
  </PropertyGroup>

  <ItemGroup>
    <Compile Remove="Migrations\20200625063143_user_table_added_for_access_control.cs" />
    <Compile Remove="Migrations\20200625063143_user_table_added_for_access_control.Designer.cs" />
    <Compile Remove="Migrations\20200625070609_test.cs" />
    <Compile Remove="Migrations\20200625070609_test.Designer.cs" />
    <Compile Remove="Migrations\20200701100225_datatype_changed_to_long_of_assetno_in_both_table.cs" />
    <Compile Remove="Migrations\20200701100225_datatype_changed_to_long_of_assetno_in_both_table.Designer.cs" />
    <Compile Remove="Migrations\20200730114532_hasShiftingRequest_field_added_in_pc.cs" />
    <Compile Remove="Migrations\20200730114532_hasShiftingRequest_field_added_in_pc.Designer.cs" />
    <Compile Remove="Migrations\20200731033230_hasShiftingRequest_field_added_in_pc.cs" />
    <Compile Remove="Migrations\20200731033230_hasShiftingRequest_field_added_in_pc.Designer.cs" />
    <Compile Remove="Migrations\20200917095552_trial.cs" />
    <Compile Remove="Migrations\20200917095552_trial.Designer.cs" />
    <Compile Remove="Migrations\20201208042418_test.cs" />
    <Compile Remove="Migrations\20201208042418_test.Designer.cs" />
    <Compile Remove="Migrations\20201208054030_User_table_mapped_with_laptop_and_desktop.cs" />
    <Compile Remove="Migrations\20201208054030_User_table_mapped_with_laptop_and_desktop.Designer.cs" />
  </ItemGroup>

  <ItemGroup>
    <Content Remove="Views\AssetDataLaptops\Delete.cshtml" />
    <Content Remove="Views\AssetDataPcs\Delete.cshtml" />
    <Content Remove="Views\AssetShiftings\Delete.cshtml" />
    <Content Remove="Views\AssetShiftings\Details.cshtml" />
    <Content Remove="Views\AssetShiftings\Edit.cshtml" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="bootstrap" Version="4.6.0" />
    <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="5.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.2" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.11" />    
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.11" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.11">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.Office.Interop.Excel" Version="15.0.4795.1000" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration" Version="3.1.4" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.4" />
    <PackageReference Include="System.DirectoryServices" Version="5.0.0" />
    <PackageReference Include="System.DirectoryServices.AccountManagement" Version="5.0.0" />
  </ItemGroup>



</Project>

EDIT 2:

Getting build error after degrading EntityFrameworkCore 5 to 3.x

enter image description here


Solution

  • Because your project version is 3.1,you should not use package <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.2" />.

    You need change it to 3.x.