为什么使用 EF 4.1 代码的 MySQL DB 连接器每次第一次都会失败?
每当我的 MVC/“EF 4.1 代码优先”Web 应用程序第一次尝试访问数据库时,都会出现以下异常:
[MySqlException (0x80004005): Access denied for user 'SomeUser'@'94.45.23.90' (using password: NO)]
MySql.Data.MySqlClient.MySqlStream.ReadPacket() +250
MySql.Data.MySqlClient.NativeDriver.AuthenticateNew(Boolean reset) +482
MySql.Data.MySqlClient.NativeDriver.Open() +1186
MySql.Data.MySqlClient.Driver.Open() +245
MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings) +294
MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection() +18
MySql.Data.MySqlClient.MySqlPool.GetPooledConnection() +403
MySql.Data.MySqlClient.MySqlPool.TryToGetDriver() +228
MySql.Data.MySqlClient.MySqlPool.GetConnection() +106
MySql.Data.MySqlClient.MySqlConnection.Open() +1251
System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) +67
[EntityException: The underlying provider failed on Open.]
System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) +11109774
System.Data.EntityClient.EntityConnection.Open() +142
System.Data.Objects.ObjectContext.EnsureConnection() +97
System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) +66
System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() +47
System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source) +220
System.Linq.Queryable.FirstOrDefault(IQueryable`1 source) +383
System.Data.Entity.Internal.InternalContext.QueryForModelHash() +349
System.Data.Entity.Internal.InternalContext.CompatibleWithModel(Boolean throwIfNoMetadata) +109
System.Data.Entity.CreateDatabaseIfNotExists`1.InitializeDatabase(TContext context) +360
System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) +64
[DataException: An exception occurred while initializing the database. See the InnerException for details.]
System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) +152
System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() +199
System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input) +193
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action) +235
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +39
System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +89
System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() +21
System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider() +44
System.Linq.Queryable.Where(IQueryable`1 source, Expression`1 predicate) +135
Got.Data.Infrastructure.RepositoryBase`2.GetMany(Expression`1 where) in C:\Users\Eran\Documents\ForumTel\GotMvcConvert\Got.Data\Infrastructure\RepositoryBase.cs:79
Got.Services.ProductService.GetSignUpProducts() in C:\Users\Eran\Documents\ForumTel\GotMvcConvert\Got.Services\ProductService.cs:27
Got.Web.Controllers.HomeController.Products(Nullable`1 category) in C:\Users\Eran\Documents\ForumTel\GotMvcConvert\Got.Web\Controllers\HomeController.cs:37
lambda_method(Closure , ControllerBase , Object[] ) +118
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +264
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +39
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +129
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +826410
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +826410
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +826410
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +314
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +825632
System.Web.Mvc.Controller.ExecuteCore() +159
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +54
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375
刷新页面后,它工作正常。但是在每次编译/应用程序卸载后,我都会在第一次数据库加载时遇到此异常。
我使用 MySql 连接器 v6.4.3.0。
我该如何解决这个问题?
Whenever my MVC/"EF 4.1 code first" web application tries to access the data base for the first time it gives me the following exception:
[MySqlException (0x80004005): Access denied for user 'SomeUser'@'94.45.23.90' (using password: NO)]
MySql.Data.MySqlClient.MySqlStream.ReadPacket() +250
MySql.Data.MySqlClient.NativeDriver.AuthenticateNew(Boolean reset) +482
MySql.Data.MySqlClient.NativeDriver.Open() +1186
MySql.Data.MySqlClient.Driver.Open() +245
MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings) +294
MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection() +18
MySql.Data.MySqlClient.MySqlPool.GetPooledConnection() +403
MySql.Data.MySqlClient.MySqlPool.TryToGetDriver() +228
MySql.Data.MySqlClient.MySqlPool.GetConnection() +106
MySql.Data.MySqlClient.MySqlConnection.Open() +1251
System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) +67
[EntityException: The underlying provider failed on Open.]
System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) +11109774
System.Data.EntityClient.EntityConnection.Open() +142
System.Data.Objects.ObjectContext.EnsureConnection() +97
System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) +66
System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() +47
System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source) +220
System.Linq.Queryable.FirstOrDefault(IQueryable`1 source) +383
System.Data.Entity.Internal.InternalContext.QueryForModelHash() +349
System.Data.Entity.Internal.InternalContext.CompatibleWithModel(Boolean throwIfNoMetadata) +109
System.Data.Entity.CreateDatabaseIfNotExists`1.InitializeDatabase(TContext context) +360
System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) +64
[DataException: An exception occurred while initializing the database. See the InnerException for details.]
System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) +152
System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() +199
System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input) +193
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action) +235
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +39
System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +89
System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() +21
System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider() +44
System.Linq.Queryable.Where(IQueryable`1 source, Expression`1 predicate) +135
Got.Data.Infrastructure.RepositoryBase`2.GetMany(Expression`1 where) in C:\Users\Eran\Documents\ForumTel\GotMvcConvert\Got.Data\Infrastructure\RepositoryBase.cs:79
Got.Services.ProductService.GetSignUpProducts() in C:\Users\Eran\Documents\ForumTel\GotMvcConvert\Got.Services\ProductService.cs:27
Got.Web.Controllers.HomeController.Products(Nullable`1 category) in C:\Users\Eran\Documents\ForumTel\GotMvcConvert\Got.Web\Controllers\HomeController.cs:37
lambda_method(Closure , ControllerBase , Object[] ) +118
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +264
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +39
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +129
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +826410
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +826410
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +826410
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +314
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +825632
System.Web.Mvc.Controller.ExecuteCore() +159
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +54
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375
After I refresh the page it works fine. But after every compilation/application unload, I get this exception for the first DB load.
I use MySql connector v6.4.3.0.
How can I solve that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为它已在 MySQL 连接器 v6.4.4.0 中修复。
I think it's fixed in MySQL connector v6.4.4.0.