EF + MySQL problem ("Unable to find the requested .Net Framework Data Provider")

Discussion in 'Databases' started by johnb, Oct 23, 2010.

  1. I'm creating an asp.net MVC site, which uses the Entity Framework over a MySQL database. It runs fine locally, but on the server instantiating the object context generates this exception:

    I've tried copying across System.Data.Entity.dll but that didn't help, so I assume there's something amiss with my config file but I'm not sure what. The connection string section looks like this:
    HTML:
    <connectionStrings>
        <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
        <add name="DataContext" connectionString="metadata=res://*/DataContext.csdl|res://*/DataContext.ssdl|res://*/DataContext.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=<server name>;User Id=<User Id>;password=<password>;Persist Security Info=True;database=<database>&quot;" providerName="System.Data.EntityClient" />
    </connectionStrings>
    Any suggestions? I'm running this on .net 3.5.

    Thanks in advance.
     
  2. Ray

    Ray

    Do you have a URL we can look at?
     
  3. Sorry for late reply. Yes, here - currently just the default MVC project:
    http://www.jdbrunton.com/Account/LogOn

    Try logging in to reproduce the exception.

    Full stack trace:

    Code:
    [ArgumentException: Unable to find the requested .Net Framework Data Provider.  It may not be installed.]
       System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName) +1312703
       System.Data.EntityClient.EntityConnection.GetFactory(String providerString) +34
    
    [ArgumentException: The specified store provider cannot be found in the configuration, or is not valid.]
       System.Data.EntityClient.EntityConnection.GetFactory(String providerString) +63
       System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString) +377
       System.Data.EntityClient.EntityConnection..ctor(String connectionString) +79
       System.Data.Objects.ObjectContext.CreateEntityConnection(String connectionString) +41
       System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName) +17
       Core.DataContext..ctor() in datacontext.designer.cs:26
       Core.Services.UserService.ValidateUser(String userName, String password) in UserService.cs:20
       Test.Controllers.UserProvider.ValidateUser(String username, String password) in AccountController.cs:332
       Test.Controllers.AccountMembershipService.ValidateUser(String userName, String password) in AccountController.cs:355
       Test.Controllers.AccountController.ValidateLogOn(String userName, String password) in AccountController.cs:106
       Test.Controllers.AccountController.LogOn(String userName, String password, Boolean rememberMe, String returnUrl) in AccountController.cs:61
       lambda_method(ExecutionScope , ControllerBase , Object[] ) +245
       System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
       System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +178
       System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +24
       System.Web.Mvc.<>c__DisplayClassa.<InvokeActionMethodWithFilters>b__7() +53
       System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +258
       System.Web.Mvc.<>c__DisplayClassc.<InvokeActionMethodWithFilters>b__9() +20
       System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +193
       System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +336
       System.Web.Mvc.Controller.ExecuteCore() +108
       System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +23
       System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7
       System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) +114
       System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext) +39
       System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext) +7
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
    
     
  4. Ray

    Ray

    I'm a little confused, are you using SQL 2008 for your membership/roles or are you using MySQL?
     
  5. It should all be MySQL, accessed through the Entity Framework. Is there something there which suggests otherwise?

    Thanks
    John
     
  6. (Oh - if you're asking because the default MVC project uses SQL 2008, I've replaced the code dealing with membership/roles.)
     
  7. Ray

    Ray

    Last edited by a moderator: Oct 14, 2015
  8. Same problem with Entity Framework and MySql

    Hello,

    I'm getting exactly the same error as johnb. I believe Ray's last post isn't sufficient for this subject because the error is about .Net Framework Data Provider missing. I'm using .Net Framework 4.0. Here's the link where I got the error: http://www.carlosgomes.com.pt/StatusInsert.aspx.
    I've added MySql.Data.dll, MySql.Data.Entity.dll and MySql.Web.dll to bin folder.

    Kind regards,
    Carlos
     
  9. Ray

    Ray

    What do you have in your applications web.config file. Did you read the link I posted and made sure that all the required elements are created in your applications web.config file? And don't forget you need to upload the correct web assemblies in your applications Bin folder such as the mysql.web component.
     
  10. I've added the following to web.config and works fine:
    Code:
    <DbProviderFactories>
          <clear />
          <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.3.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
        </DbProviderFactories>
    The MySql Connector Net 3.6.5 installs on GAC version 6.3.5.0 of MySql.Data.dll and version 6.3.4.0 of MySql.Data.Entity.dll. VS 2010 loads those versions and I needed to change manually MySql.Data.Entity.dll to 6.3.5.0 and upload it (I find it on [Program Files]\MySQL\MySQL Connector Net 6.3.5\Assemblies\v4.0).
     
  11. Ray

    Ray

    The MySQL .Net Connector we have installed on the servers GAC is version 6.2.3. However, you do not need to use our .Net connector you can simply upload your version in your applications Bin folder and reference it there.
     

Share This Page