一个 asp.net core 程序,之前在 .net core 3.0 preview 4 上可以正常运行,昨天升级到 preview 5 后运行时出现下面的错误:
Microsoft.AspNetCore.Server.Kestrel
System.TypeLoadException: Could not load type 'Microsoft.EntityFrameworkCore.Metadata.RelationalAnnotationsBuilder' from assembly 'Microsoft.EntityFrameworkCore.Relational, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
at Microsoft.EntityFrameworkCore.SqlServer.Metadata.Internal.SqlServerModelBuilderAnnotations..ctor(InternalModelBuilder internalBuilder, ConfigurationSource configurationSource)
请问如何解决?
是因为 VS2019 的问题造成 Web 项目的 Microsoft.EntityFrameworkCore.SqlServer
nuget 包没有被升级,手动将
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-preview4.19216.3" />
改为
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-preview5.19227.1" />
问题就解决了