使用Pomelo MySQL EF提供程序與ASP.NET Core 2.0 Preview的錯誤

asp.net-core asp.net-core-2.0 entity-framework-core mysql pomelo

我在ASP.NET Core 2.0 Preview上使用Pomelo 1.1.2,以及EF 2.0 Preview。使用他們的演示代碼,每次調用“UseMySql”時都會出現以下異常:

System.TypeLoadException occurred
  HResult=0x80131522
  Message=Method 'Clone' in type 'Microsoft.EntityFrameworkCore.Internal.MySqlOptionsExtension' from assembly 'Pomelo.EntityFrameworkCore.MySql, Version=1.1.1.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
  Source=<Cannot evaluate the exception source>
  StackTrace:
   at Microsoft.EntityFrameworkCore.MySqlDbContextOptionsExtensions.UseMySql(DbContextOptionsBuilder optionsBuilder, String connectionString, Action`1 mySqlOptionsAction)
   at CoreTest1.Startup.<ConfigureServices>b__4_0(DbContextOptionsBuilder options) in C:\DEV\Experiments\CoreTest1\CoreTest1\Startup.cs:line 27
   at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.<>c__DisplayClass0_0`1.<AddDbContext>b__0(IServiceProvider p, DbContextOptionsBuilder b)
   at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.DbContextOptionsFactory[TContext](IServiceProvider applicationServiceProvider, Action`2 optionsAction)
   at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.<>c__DisplayClass5_0`1.<AddCoreServices>b__0(IServiceProvider p)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactoryService(FactoryService factoryService, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite singletonCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass17_0.<RealizeService>b__0(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
   at CoreTest1.Controllers.HomeController.Index() in C:\DEV\Experiments\CoreTest1\CoreTest1\Controllers\HomeController.cs:line 18
   at Microsoft.AspNetCore.Mvc.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__18.MoveNext()

想知道這是否僅僅是因為2.0預覽庫?有任何想法嗎?我試著在Git上查看他們的源代碼,看看我是否能發現任何錯誤,但不能。

一般承認的答案

讓我們來看看EF Core 2.0 Preview 1的公告

如果您使用的是第三方數據庫提供程序,請檢查它們是否已發布依賴於2.0.0-preview1-final的更新。如果有,那麼只需升級到新版本。如果沒有,那麼你將無法升級,因為版本2.0包含幾個重大更改和1. *提供商不希望使用它。

這意味著在產生可比較版本之前,預計Pomelo不會支持EF Core 2.0。


熱門答案

我使用mvc asp.net core 2.0和Pomelo.EntityFrameworkCore.MySql版本2.1.4,我無法更新我的數據庫。在軟件包管理器控制台上,我發出了一條消息“你的SQL語法有錯誤;在我嘗試使用Pomelo.EntityFrameworkCore幾次嘗試失敗後,查看與你的MySql服務器版本相對應的手冊以獲得正確使用的語法...”。 MySql版本2.0.0,最後我在遊戲中......



Related

許可下: CC-BY-SA with attribution
不隸屬於 Stack Overflow
許可下: CC-BY-SA with attribution
不隸屬於 Stack Overflow