0

Some weeks before i encountered similar problem of scaffolding error and got the solution. What am i trying is controllers>add>new scaffolded item >MVC controller with views , using entity framework

Link:-

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

But the thing is I'm facing that problem again.

enter image description here

My cproj file :

<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.EntityFrameworkCore" Version="3.1.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.4" />    
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.4">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <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" />
    <PackageReference Include="System.Management" Version="5.0.0" />
  </ItemGroup>

  <ItemGroup>
    <Folder Include="LocationReports\" />
  </ItemGroup>
</Project>

Note :-

I have tried....

-clean and rebuild

-updating all packages

-clear nuget cache

-delete .vs folder and open project and clean/rebuild

-disabling offline nuget package source

-add "https://api.nuget.org/v3/index.json" in nuget package sources

-downgraded all package to 3.1.4 and made same version

  • try restart Visual Studio. and before opening it again, go to `C:\Users\YourUserName\AppData\Local\Microsoft\VisualStudio\VsVersion\ComponentModelCache` and delete files in the ComponentModelCache folder – A H Mar 30 '21 at 09:56
  • @enduser tried but not working – parthraj panchal Mar 30 '21 at 10:15
  • Which version of Visual studio 2019 are you using? Perhaps the issue relates the Visual Studio version, try to update the Visual Studio to the latest version. – Zhi Lv Mar 31 '21 at 06:31
  • @ZhiLv current visual studio version im using 16.9.2 actually i uninstalled all nuget packages forcefully and reinstalled them one by one and my issue is resolved now. i dont know what was causing the issue but it did work. – parthraj panchal Apr 02 '21 at 05:05
  • Glad to hear you have resolved the problem. Perhaps, the issue is related the CodeGeneration nuget package version. – Zhi Lv Apr 02 '21 at 05:25

0 Answers0