Bug #73224 Configuration Error, MySql Simple Membership Provider
Submitted: 7 Jul 2014 20:34 Modified: 15 Aug 2014 20:49
Reporter: Michał Małyska Email Updates:
Status: Not a Bug Impact on me:
Category:Connector / NET Severity:S2 (Serious)
Version:6.9.1 OS:Microsoft Windows
Assigned to: Francisco Alberto Tirado Zavala CPU Architecture:Any
Tags: ASP, C#, connector, membership, NET, provider, simplemembershipprovider

[7 Jul 2014 20:34] Michał Małyska
Getting Configuration error on freshly created mvc4 web application with forms authentication.

Added files to project:
all in 6.9.1 version

Updated EF5 to EF6

in web.config added membership and role providers using simple providers.

Getting error on loading web.config:
"Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: UserTableName configuration was not initialized."

Source error:
"Line 43: <add name="MySQLMembershipProvider" type="MySql.Web.Security.MySqlSimpleMembershipProvider, MySql.Web, Version=, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression="" autogenerateschema="true"/>"

How to repeat:
Create MVC4 website with forms authentication, add Mysql 6.9.1, edit web.config.
While running its stopping on loading web.config with Configuration Error that says: "Parser Error Message: UserTableName configuration was not initialized."

Simple test will be provided.
[7 Jul 2014 20:37] Michał Małyska
Simple test for lazy ppl

Attachment: mysql test.zip (binary/octet-stream, text), 567.82 KiB.

[14 Aug 2014 20:40] Francisco Alberto Tirado Zavala
Hello Michał.

I took a look to the proyect attached and I found what is causing the exception.
In the web.config, in the Membership section the provider configured is MySQLMembershipProvider, but the type specified for the provider is "MySql.Web.Security.MySqlSimpleMembershipProvider". The type that is configured must be used only if the project will use the new MySqlSimpleMembership provider added in Connector/Net 6.9.X

If you change the type from "MySql.Web.Security.MySqlSimpleMembershipProvider" to "MySql.Web.Security.MySQLMembershipProvider" the exception will not be present anymore.

Can you confirm if you added the configuration using the Web Config tool provided by MySql for Visual Studio plugin or if you added it manually?

Thanks for your time.
[15 Aug 2014 8:22] Michał Małyska
I tried using Configuration tool, but it is using 6.8.3 version and I want to work on 6.9.X, so no I wasn't using it.
I got my web.config configured by installing NuGet package with: Mysql.data, Mysql.data.entity, Mysql.web.
I changed manually MySQLMembershipProvider to MySQLSimpleMembershipProvider sane with RoleProvider. I need to change it because WebSecurity that I'm using is using SimpleMembership.
[15 Aug 2014 14:35] Francisco Alberto Tirado Zavala
Hello Michał.

If you want to use SimpleMembership in your application you need to configure the provider in a different way.
Please check the following example configuration (this information will be published in a blog post soon):
<membership defaultProvider="MySqlSimpleMembershipProvider">
    <add name="MySqlSimpleMembershipProvider" type="MySql.Web.Security.MySqlSimpleMembershipProvider,MySql.Web,Version=,Culture=neutral,PublicKeyToken=c5687fc88969c44d" applicationName="MySqlSimpleMembershipTest" description="MySQLdefaultapplication" connectionStringName="MyConnection"  userTableName="UserProfile" userIdColumn="UserId" userNameColumn="UserName" autoGenerateTables="True" />

In the previous configuration the mandatory properties are: connectionStringName, userTableName, userIdColumn, userNameColumn and autoGenerateTables. If the other properties are not provided a default value is set to it but if the mandatory properties are not set a ProviderException will be thrown. The valid properties for the MySqlSimpleMembership are the same used for MySqlMembership plus the mandatory fields.

- UserTableName: Name of the table where will be stored the user, this table is independent from the schema generated by the provider and can be edited later by the user. 
- UserId: name of the column that will store the id for the records in the userTableName. 
- UserName: name of the column that will store the name/user for the records in the userTableName. 

The connectionStringName property must match a connection string defined in web.config file. Also verify that the version in the provider configuration match the version of Connector/Net that you are using.

Thanks for your time.
[15 Aug 2014 19:17] Michał Małyska
Thank you for your time!

I changed that and it is working now.
I updated to newest version 6.9.2 and it's working too.

[15 Aug 2014 20:02] Francisco Alberto Tirado Zavala
Hello Michał.

I'm glad to know that you was able to resolve the issue.
Are you agree if we change the status of the report as not a bug?

Thanks for your time.
[15 Aug 2014 20:39] Michał Małyska
Ah, yes it is not a bug but ;) just configuration problems.
[15 Aug 2014 20:49] Francisco Alberto Tirado Zavala
Here is the link to the blog post about using SimpleMembershipProvider with MySQL Connector/Net:

Thanks for your time Michał.