0
votes

With Studio 2012 I created a MVC4-project with forms authentication using dotnet 4.0. I changed the connectionstring for the database in the web.config to use the sql-database instead of a local mdf-file.

After uploading I ran into an error you can see here:

"Could not load file or assembly 'MySql.Web, Version=6.6.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The system cannot find the file specified."

I'm sure Microsoft does not bind MySql-Assemblys into a fresh MVC4-project. I think it is a misconfiguration by 1&1.

Or is it really my fault?

1

1 Answers

0
votes

I was able to get it to work doing the following below. I'm running VS2012.2, MVC4 targeting .Net Framework 4.0. I deployed it to my .Net 4 server at my hosting provider (DiscountASP.Net).

  • Do NOT add MySQL.Data, MySQL.Data.Entities and MySQL.Web via NuGet. Instead download the .Net Connectors from the MySQL site. At the time of this post it was Version 6.6.5 for MySQL.Data, MySql.Data.Entity and MySql.Web. If you already do have them from NuGet be sure to un-install them from the package manager.

  • Manually add the MySQL asm refs for .net 4 to the project from where MySQL installs its .net Connectors (mine was in C:\Program Files (x86)\MySQL\MySQL Connector Net 6.6.5\Assemblies\v4.0). Be sure to check Copy Local for all three of the asms.

  • Add or modify the following in your web.config:

In the <configuration><connectionStrings> section:

<add name="MyProviderDbConn" connectionString="server=mysql01.someurl.com;User Id=dbuser1;Pwd=ToManySecrets;Persist Security Info=True;database=MyDbSchemaName;Use Compression=True;port=3306" providerName="MySqlMembershipProvider" />

In the <configuration><system.web> section:

<membership defaultProvider="MySqlMembershipProvider">
<providers>
<clear />
<add name="MySqlMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.6.5.0, PublicKeyToken=c5687fc88969c44d" autogenerateschema="true" connectionStringName="MyProviderDbConn" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" applicationName="/" />
</providers>
</membership>