Newly generated Blazor project cannot be run with last version of EntityFrameworkCore.
Expected result:
Project is run.
Actual Result:
While updating packages, the code generator adds line to AssemblyInfo.cs file:
[assembly: Microsoft.AspNetCore.Identity.UI.UIFrameworkAttribute("Bootstrap4")]
which cause compiler error: ProjectName.AssemblyInfo.cs(13, 42): [CS0234] The type or namespace name 'UI' does not exist in the namespace 'Microsoft.AspNetCore.Identity' (are you missing an assembly reference?)
If this generated line is deleted, then I see Unhandled exception:
MissingMethodException: Method not found: 'Boolean Microsoft.EntityFrameworkCore.Migrations.IMigrationsModelDiffer.HasDifferences(Microsoft.EntityFrameworkCore.Metadata.IModel, Microsoft.EntityFrameworkCore.Metadata.IModel)'.
MissingMethodException: Method not found: 'Boolean Microsoft.EntityFrameworkCore.Migrations.IMigrationsModelDiffer.HasDifferences(Microsoft.EntityFrameworkCore.Metadata.IModel, Microsoft.EntityFrameworkCore.Metadata.IModel)'.
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
Raw exception details:
System.MissingMethodException: Method not found: 'Boolean Microsoft.EntityFrameworkCore.Migrations.IMigrationsModelDiffer.HasDifferences(Microsoft.EntityFrameworkCore.Metadata.IModel, Microsoft.EntityFrameworkCore.Metadata.IModel)'.
at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.StartTStateMachine
at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
I was trying to downgrade versions, but nothing works.
output of dotnet --info
:
.NET Core SDK (reflecting any global.json):
Version: 3.1.302
Commit: 41faccf259
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.1.302/
Host (useful for support):
Version: 3.1.6
Commit: 3acd9b0cd1
.NET Core SDKs installed:
1.0.0-preview2-003121 [/usr/local/share/dotnet/sdk]
1.0.3 [/usr/local/share/dotnet/sdk]
2.0.0 [/usr/local/share/dotnet/sdk]
2.1.4 [/usr/local/share/dotnet/sdk]
2.1.302 [/usr/local/share/dotnet/sdk]
2.1.505 [/usr/local/share/dotnet/sdk]
3.1.200 [/usr/local/share/dotnet/sdk]
3.1.300 [/usr/local/share/dotnet/sdk]
3.1.302 [/usr/local/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 1.0.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 1.1.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.18 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.20 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
@ajcvickers do you know whether there was any breaking change which could have caused this?
@mkArtakMSFT Not that I am aware of. /cc @bricelam
@Lionberg Can you post the contents of your csproj
file?
@Lionberg moving to EF repo so that you can deal with this there. Thanks!
@Lionberg Does following the guidance in the document linked by @smitpatel help you past this?
@Lionberg Make sure to upgrade all ASP.NET packages to a matching 5.0 version
@Lionberg Make sure to upgrade all ASP.NET packages to a matching 5.0 version
I also get this issue, does this mean I can't use EFCore with .NET Core 3.1?
@AmSmart No, it means that you will need to follow the guidance in the breaking changes docs: https://docs.microsoft.com/en-us/ef/core/what-is-new/ef-core-5.0/breaking-changes#relational-model
@ajcvickers
Oh! Thanks. Just tested it, it's working great. Absolutely loved your demo on Many to Many relationships. Great job from you and the team.
@AmSmart Thanks. Glad you enjoyed it. :-)
@AmSmart just to clarify in the documentation that @ajcvickers mentioned it gives updated code for the differ, but this isn't my code, it's internal to the DatabaseErrorPage.
For anyone else coming across this issue on a 3.1 -> 5.0 project (specifically: where ASP.NET Core 3.1 is being used still, but with EF 5.0), removing the call to app.UseDatabaseErrorPage()
in Configure()
will resolve the error on startup.
Most helpful comment
@AmSmart just to clarify in the documentation that @ajcvickers mentioned it gives updated code for the differ, but this isn't my code, it's internal to the DatabaseErrorPage.
For anyone else coming across this issue on a 3.1 -> 5.0 project (specifically: where ASP.NET Core 3.1 is being used still, but with EF 5.0), removing the call to
app.UseDatabaseErrorPage()
inConfigure()
will resolve the error on startup.