ingh.am
ingh.am

Reputation: 26742

Setting up MySQL with ASP.NET MVC 3

I'm currently using Visual Studio 2010 and have created a 'ASP.NET MVC 3 Web Application'.

I've changed the question from SQLite to MySQL for reasons pointed out by Darin.

So I've setup my MySQL database and configured the web.config as shown in this answer, however I get instant configuration error on this:

Parser Error Message: Could not load file or assembly 'MySql.Web, Version=6.2.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The system cannot find the file specified.

Line 78: type="MySql.Web.Security.MySQLRoleProvider, MySql.Web

Is this because the public key is wrong?

Thanks

Upvotes: 1

Views: 4691

Answers (4)

JuanMa
JuanMa

Reputation: 131

The file is there but versions don't match. Check if you are specifying the correct version for your MySql Connector. This solved the problem for me.

Change Version=6.2.2.0 to the one you are using wherever it applies.

Upvotes: 1

Mike O'Connor
Mike O'Connor

Reputation: 3803

What version of the MySQL connector do you have installed? I saw that error message when I had mismatched the version numbers, and it went away when I corrected them. You can check the version by looking at the properties of the item in the references section.

Once that's working, you may also need to add a default membership provider. All you need to do is change <membership> to <membership defaultProvider="MySqlMembershipProvider">.

I also followed the instructions here which added a bunch of tables to the specified database related to membership, profiles, and roles. Not sure if that was required, but something to try if you're still running into issues.

Hope this helps!

Upvotes: 0

Richard
Richard

Reputation: 22016

Try this

<add name="ApplicationServices"
         connectionString="Data Source=|DataDirectory|sqlite.db;Version=3;"
         providerName="System.Data.SqLite" />

If you need sqlite membership provider look here:

http://www.codeproject.com/KB/aspnet/SQLiteProviders.aspx

Upvotes: 0

Darin Dimitrov
Darin Dimitrov

Reputation: 1038720

You will need to write a custom membership provider which works with SQLite. Here's an example with MySQL. Also notice that SQLite is not intended to be used in a multithreaded environment such as ASP.NET.

Upvotes: 1

Related Questions