Identity Scaffolding to existing project is broken
See original GitHub issueDescribe the bug
Attempting to scaffold the Identity views into an existing .NET 5 project which references v5.0.5 of the Identity libraries does not work. The tool down-grades the NuGet package references, then complains that there are build errors because the site references a lower version of the packages than a referenced class library.
To Reproduce
Using Visual Studio 2019 v16.9.4, create a new solution with two projects:
- A .NET 5.0 class library;
- An ASP.NET 5.0 site;
In the class library, reference Microsoft.AspNetCore.Identity.EntityFrameworkCore
version 5.0.5
, and Microsoft.EntityFrameworkCore
version 5.0.5
. Create a class derived from IdentityContext
.
In the site, reference the class library, and reference Microsoft.AspNetCore.Identity.UI
version 5.0.5
. Configure identity to use the context from the class library.
Verify that the solution builds without errors.
Right-click on the site and select “Add -> New Scaffolded Item”. Walk through the steps to scaffold the Identity views, as described in the documentation, selecting the correct context from the drop-down list.
After a while, the operation fails with an error:
The Identity and EF Core references in the site have been down-graded to version 5.0.4
, and the site now fails to build because the class library references a higher version!
Further technical details
.NET SDK (reflecting any global.json): Version: 5.0.202 Commit: db7cc87d51
Runtime Environment: OS Name: Windows OS Version: 10.0.19042 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\5.0.202\
Host (useful for support): Version: 5.0.5 Commit: 2f740adc14
Microsoft Visual Studio Professional 2019 Version 16.9.4 VisualStudio.16.Release/16.9.4+31205.134 Microsoft .NET Framework Version 4.8.04084 Installed Version: Professional
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:17 (4 by maintainers)
Top GitHub Comments
Since 5.0.10 I’m unable to roll anything back because the first order of business when scaffolding Identity is to bring the corresponding packages up to date - which means every attempt to scaffold returns a rollback error. I have found an interim fix here which solved my issue. This article was written in February and people have been thanking the author all year. I hope it helps you too.
Created a new Blazor Net Core Hosted application with default IdentityServer & EntityFramework packages Version=“5.0.9” and received the same critical error during a scaffolding attempt overriding all. I changed the packages down to 5.0.8 and ran the scaffold again which this time completed successfully. Microsoft Visual Studio Community 2019 Preview Version 16.11.0 Preview 2.0