Search code examples
c#asp.net-core-identity.net-core-3.0

.NET Core 3.0 Identity issue


I'm trying to update my projects to .NET Core 3.0 and .NET Standard 2.1 (including .NET Core Identity)

I have 2 projects. First my Web API:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
    <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0" />
  </ItemGroup>
...

And in this project code related with Identity works fine.

As I see here I need to remove package Microsoft.AspNetCore.Identity https://learn.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.0&tabs=visual-studio

2-nd project:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <!--<FrameworkReference Include="Microsoft.AspNetCore.App" />-->
    <!--<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />-->
  </ItemGroup>
...

So, if I remove Microsoft.AspNetCore.Identity from my second project I see error:

The type or namespace name 'SignInManager<>' could not be found (are you missing a using directive or an assembly reference?)

If I add this line:

<FrameworkReference Include="Microsoft.AspNetCore.App" />

I see this error:

Error NETSDK1073 The FrameworkReference 'Microsoft.AspNetCore.App' was not recognized

How can I resolve my issue?


Solution

  • See this Github Issue which explains a lot of the changes. As said in one of the comments.

    Correct. We are removing the netstandard2.0 from most Microsoft.AspNetCore.* assemblies. See #3754

    So in order to use the <FrameworkReference Include="Microsoft.AspNetCore.App" /> in your .csproj you will need to target netcoreapp3.0 or higher.