gpt4 book ai didi

c# - 将 ASP.NET MVC3 网站连接到 MySQL 时出现问题

转载 作者:行者123 更新时间:2023-11-29 00:25:32 27 4
gpt4 key购买 nike

我在将我的网站 (asp.net mvc3) 连接到 MySQL 时遇到问题。

本地主机正在运行,但在服务器上我收到以下错误:

Error: Unable to locate the Data Provider. Requested Net Framework. Maybe it is not installed.

Stacktrace: [ArgumentException: The repository provider specified is not found in the configuration or is not valid.]
System.Data.EntityClient.EntityConnection.GetFactory(String providerString) +11468668
System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString) +575
System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, AppConfig config) +144 ... +21 System.Data.Entity.Infrastructure.DbQuery1.System.Linq.IQueryable.get_Provider()
+44 System.Linq.Queryable.Where(IQueryable
1 source, Expression1 predicate) +85 AcusticoA3.Controllers.HomeController.Index() +978
lambda_method(Closure , ControllerBase , Object[] ) +79<br/>
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext
controllerContext, IDictionary
2 parameters) +264
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2
parameters) +39<br/>
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12()
+124 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter
filter, ActionExecutingContext preContext, Func
1 continuation) +727142 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList1 filters, ActionDescriptor actionDescriptor,
IDictionary
2 parameters) +309
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +727076
System.Web.Mvc.Controller.ExecuteCore() +159
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +334 System.Web.Mvc.<>c_DisplayClassb.b_5() +62 System.Web.Mvc.Async.<>c_DisplayClass1.b_0() +15 System.Web.Mvc.<>c_DisplayClasse.b_d() +52
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288

我正在使用 Mysql.connector 6.6.5.0 和 EntityFramework 5.0。

我的连接字符串:

  <connectionStrings>
<add name="MyEntities" connectionString="metadata=res://*/Models.Model.csdl|res://*/Models.Model.ssdl|res://*/Models.Model.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=[HOST];user id=[USER]; password=[PASSWORD]; database=[DATABASE]&quot;" providerName="System.Data.EntityClient"/> </connectionStrings>

最佳答案

我解决了。

只需将提供程序dll 放入bin 文件夹并在Web.config 中进行设置:

  <system.data>
<DbProviderFactories>
<clear />
<remove invariant="MySQL Data Provider"/>
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.6.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories> </system.data>

请记住更改提供程序版本。

关于c# - 将 ASP.NET MVC3 网站连接到 MySQL 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19106840/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com