Unable to scaffold AspNetCore Identity for .Net Core 3.0
See original GitHub issueDescribe the bug
I was unable to scaffold the AspNetCore Identity with aspnet-codegenerator. I followed this guide thoroughly and even made a new MVC project with the dotnet new mvc -au Individiual
command - to no avail.
I also tried to update the aspnet-codegenerator, but nothing worked.
To Reproduce
- Generate a new MVC application with
dotnet new mvc -au Individual
- Install the aspnet codegenerator with
dotnet tool install -g dotnet-aspnet-codegenerator
- Add the references, and packages which is the second step here
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet add package Microsoft.EntityFrameworkCore.Design
dotnet add package Microsoft.AspNetCore.Identity.EntityFrameworkCore
dotnet add package Microsoft.AspNetCore.Identity.UI
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
dotnet add package Microsoft.EntityFrameworkCore.Tools
Step 3 gave us this output:
obj/Debug/netcoreapp3.0/box.AssemblyInfo.cs(10,42): error CS0234: The type or namespace name 'UI' does not exist in the namespace 'Microsoft.AspNetCore.Identity' (are you missing an assembly reference?) [/Users/brianchew/Desktop/Project/box.csproj]
Startup.cs(7,37): error CS0234: The type or namespace name 'UI' does not exist in the namespace 'Microsoft.AspNetCore.Identity' (are you missing an assembly reference?) [/Users/brianchew/Desktop/Project/box.csproj]
The build failed. Fix the build errors and run again.
watch : Exited with error code 1
- Run the aspnet-codegenerator identity -h
Output of aspnet-codegenerator identity -h
Usage: aspnet-codegenerator [arguments] [options]
Arguments:
generator Name of the generator. Check available generators below.
Options:
-p|--project Path to .csproj file in the project.
-n|--nuget-package-dir
-c|--configuration Configuration for the project (Possible values: Debug/ Release)
-tfm|--target-framework Target Framework to use. (Short folder name of the tfm. eg. net46)
-b|--build-base-path
--no-build
Selected Code Generator: identity
No code generator found with the name 'identity'.
No code generators are available in this project. Please add the 'Microsoft.VisualStudio.Web.CodeGeneration.Design' NuGet package to the project. Please add Microsoft.VisualStudio.Web.CodeGeneration.Design package to the project as a NuGet package reference.
RunTime 00:00:01.12
Further technical details
project.csproj file
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<UserSecretsId>**************************************</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<None Update="app.db" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.0" />
</ItemGroup>
</Project>
dotnet --info output
.NET Core SDK (reflecting any global.json):
Version: 3.0.101
Commit: bc5f8df0f5
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.15
OS Platform: Darwin
RID: osx.10.15-x64
Base Path: /usr/local/share/dotnet/sdk/3.0.101/
Host (useful for support):
Version: 3.0.1
Commit: 32085cbc72
.NET Core SDKs installed:
2.1.802 [/usr/local/share/dotnet/sdk]
3.0.100 [/usr/local/share/dotnet/sdk]
3.0.101 [/usr/local/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.13 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.13 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.13 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.14 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes
Any help is greatly appreciated. The only other workaround I found was to use a windows machine, and manually scapfold this with Visual Studio Community 2019.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Scaffold Identity in ASP.NET Core projects
From the left pane of the Add New Scaffolded Item dialog, select Identity. Select Identity in the center pane. Select the Add button....
Read more >Net Core: Unable to Scaffold Identity from Data Access ...
You have to clear the NuGet Cache. To do this ->. -> Go to Tools -> Options -> NuGet Package Manager -> General...
Read more >ASP.NET Core: Identity Scaffolding
In Visual Studio right-click on the project and select Add > New Scaffolded Item. On the Add Scaffold dialog in the left list...
Read more >.NET Identity Scaffolding Error - YouTube
If you are taking a . NET Course, where we are using the . NET Identity Class Library for Authentication. Then with the...
Read more >ASP NET CORE Can't scaffold Identity using existing DbContext
Coding example for the question ASP NET CORE Can't scaffold Identity using existing DbContext - how do I specify options when scaffolding?
Read more >Top Related Medium Post
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, we have a documentation update coming soon.
Thanks.
Hi, We do not support using the CodeGeneration.Design package v 3.1.0 in a netcoreapp3.0 project. I would recommend either using a netcoreapp3.1 project or downgrading your packages to 3.0.0. Unfortunately, “dotnet add PACKAGE” does not care about project tfm and will install the latest stable package(3.1.0 currently).