STEPS TO REPRODUCE ERROR - WITH IDENTITY
- Create a new ASP.NET MVC Core Project
- Select .NET 7.0
- Select Identity
- Build
- Change DefaultConnection string to point to local database in appsettings.json
- Run Update-Database
- Right click on project and select Add => New Scafffolded Item
- Select overrides (Login, Logout, Register)
The error occurs at this point.
I tried repeating steps 7 and 8, starting from the Areas, Identity, and Pages folders respectively. I got the same error.
My Project File
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-LeaveManagement.Web-691c846b-101e-491b-b804-6cc534a6a891</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="7.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.3" />
</ItemGroup>
</Project>
appsettings.json
"ConnectionStrings": {
"DefaultConnection": "Server=DESKTOP-F66RQ22;Database=LeaveManagement;Trusted_Connection=True;Encrypt=False;MultipleActiveResultSets=true"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Error Message
I receive the same error message regardless of the targeted framework (.NET 7 vs .NET 6)
The project's folder structure is the default generated by Visual Studio.