This project is read-only.

migration from SQL Server to MySQL _ ASP.NET 4 and EnterpriseLibrary 5.0

Dec 27, 2011 at 10:20 PM
I am trying to connect from a SQL Server connection string (commented out in the web.config) to a mysql one.
I am getting the following error :
The type Database cannot be constructed...

My web.config is as follows :

<!--New config file by IB -->

<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
<section name="membase" type="Membase.Configuration.MembaseClientSection, Membase" />
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings,Microsoft.Practices.EnterpriseLibrary.Data"/>

Bucket is optional and can be specified in the constructor, so you
can use the same configuration to connect to different buckets in the cluster.

You must provide userName and password if the server is "secured" (membase is secured by default).

- bucketPassword (optional) : set the password of your bucket. Optional for membase 1.6+ where the client canfind this out automatically.
- retryCount (optional, default 0): the number of times to reconnect to a pool url before marking it as dead. (useful for ec2/amazon where the load balancer closes our connection to the pool)
- retryTimeout (optional, default 2secs): the time to wait between two retry attempts
<servers bucket="enyim" bucketPassword="pwd" userName="Administrator" password="pwd" retryCount="2" retryTimeout="00:00:02">
Provide at least 2-3 urls from your cluster.
Usually you only need to change the host, except when connecting to older versions.
Membase uses port 8091, while the NorthScale Memcached Server (1.0.3) uses 8080
<add uri="" />
<add uri="" />
<!-- the client waits deadTmimeout time to reconnect to the pool when all the specified urls are down -->
<socketPool connectionTimeout="00:00:10" deadTimeout="00:00:10" />
<errorMail from="" to=";;" subject="Error Log"
smtpServer="" userName="" password="pwd" useSsl="true" async="true"/>

<!--<add name="CloudMobDSN" connectionString="Data Source=\sqlexpressr2;Initial Catalog=cloudmob;Persist Security Info=True;User ID=cloudmob;Password=pwd" providerName="System.Data.SqlClient" /> -->
<add name="CloudMobDSN" providerName="dotConnect for MySQL" connectionString="host=;port=3306;database=cloudmob_dbo;User id=root;Password=pwd" />

<dataConfiguration defaultDatabase="CloudMobDSN">
<add databaseType="Devart.Data.MySql.EnterpriseLibrary.MySqlDatabase,Devart.Data.MySql.EnterpriseLibrary" name="dotConnect for MySQL" />

<customErrors mode="Off" />
<httpRuntime requestValidationMode="2.0"/>
<add name="HttpGet" />
<add name="HttpPost" />

<compilation debug="true" >
<add assembly="MySql.Data, Version=, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />

<authentication mode="Forms">
<forms name="CMob" loginUrl="~/Login.aspx" timeout="2880" cookieless="UseDeviceProfile" path="/" />
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
<clear />
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
<roleManager enabled="false">
<clear />
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
<pages enableViewStateMac="false" enableSessionState="true">
<add src="~/Controls/UpdateProgressBar.ascx" tagName="ProgressBar" tagPrefix="uc" />
<add namespace="DAL.WebControls.Grid" tagPrefix="ctrl" />
<add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="cc1" />


<!--Start of Mail Settings-->
<!--For -->
<!--<add key="reCaptchaPublicKey" value="6Lf9g8QSAAAAAJuHSZkTJBa-zsfL9pvXKvDu5FtW"/>
<add key="reCaptchaPrivateKey" value="6Lf9g8QSAAAAABQN891kjX1cucMeHWo9Q-wEErCP"/>-->

<!--For -->
<add key="reCaptchaPublicKey" value="6LdFjMQSAAAAAAd9MXgikq_RY7EAEQPMDMqvesOu" />
<add key="reCaptchaPrivateKey" value="6LdFjMQSAAAAACVwkTShDOK6v_v_QL6d_0Amcryu" />

<!--For Local host -->
<!--<add key="reCaptchaPublicKey" value="6Lfmi8QSAAAAALiQ8g4RLvSEP4j-rtLtCE9n7i0b"/>
<add key="reCaptchaPrivateKey" value="6Lfmi8QSAAAAAAYcnj0Oj724C6t96Jk3ZiGs5YAp"/>-->

<add key="MailServer" value=""/>
<add key="UID" value=""/>
<add key="PWD" value="pwd"/>
<add key="MailFrom" value=""/>
<add key="MailCC" value=""/>
<!--End of Mail Settings-->
<add key="FooterText" value="&amp;copy 2000 - 2012 CloudMob Media. All Rights Reserved." />
<add key="EmailTemplate" value="~/EmailBodyContent/Template1.html" />

<!--Help Default Images-->
<add key="HelpTextImage" value="hintTick.png" />
<add key="TitleArrowImage" value="hintPointer.png" />
<!--For Schedular-->
<add key="AdminMailTo" value="" />
<add key="ValidIPForScheduler" value="," />
<add key="ChartImageHandler" value="Storage=file; Timeout=180; Url=~/TempImages/; deleteAfterServicing=false" />
<add key="TempImageFolder" value="~/TempImages/"/>
<!-- Specifies the days the creatives will be served as random before performance wise selection takes place-->
<add key="ServeCreativeRandomlyDays" value="7" />
<!--For Campaign mail-->
<add key="AdminMail" value=""/>
<add key="IsAdvertiserAdmin" value="true"/>
<add key="IsAgencyAdmin" value="true"/>
<!--For Contact Template-->
<add key="ContactMail" value=""/>
<!--For Error Log-->
<add key="FilePath" value="~/ErrorLog/MessageLog.txt"/>
<!--Password for Membase-->
<add key="MembasePassword" value="pwd" />
<!--For Error Log-->
<add key="FilePath" value="~/ErrorLog/MessageLog.txt"/>

<add value="login.aspx" />
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true" />


I have downloaded the dotConnect for mySql and copied the dlls in my bin dir.

Can you help ?
Dec 28, 2011 at 3:55 AM
Edited Dec 28, 2011 at 3:59 AM

Hi iunabilly,

From what I can gather from your web.config, you are missing a few things that may be causing your problem. For example, you connectionstring has an incorrect providerName. If you are using mysql, it should be set as providerName="MySql.Data.MySqlClient". Also, NearForums uses the DbProviderFactory class to be database-agnostic, so you need to set the correct implementation of that class in the DbProviderFactories section of the web.config inside the configuration section:

			<remove invariant="MySql.Data.MySqlClient"/>
			<add invariant="MySql.Data.MySqlClient" name="MySQL Data Provider" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data"/>

As a side note, NearForums does not use Enterprise Library, so you don't need it, unless, of course, you are using it for some other application. Also you should consider removing any sensitive information on that config that you posted.

Please let us know if the above suggestion works for you and If we can help you with something else.

Kind Regards,


Dec 28, 2011 at 2:47 PM
Edited Dec 28, 2011 at 5:30 PM

Thanks Jason. I have added the DBProvider block.

I had to change the providerMappings block as follows :


<dataConfiguration defaultDatabase="CloudMobDSN">
 <add name="MySql.Data.MySqlClient" databaseType="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data,Version=,Culture=neutral,PublicKeyToken=c5687fc88969c44d"/>


Now i have another error :



The type MySqlClientFactory does not contain the ConfigurationElementTypeAttribute.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The type MySqlClientFactory does not contain the ConfigurationElementTypeAttribute.




Did i make a new mistake ?

Dec 28, 2011 at 5:30 PM

Also now i took out the dataConfiguration section and i am getting this error :


Parameter discovery is not supported for connections using GenericDatabase. You must specify the parameters explicitly, or configure the connection to use a type deriving from Database that supports parameter discovery.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NotSupportedException: Parameter discovery is not supported for connections using GenericDatabase. You must specify the parameters explicitly, or configure the connection to use a type deriving from Database that supports parameter discovery.

Dec 29, 2011 at 11:54 PM


It is very difficult to grant support to your solution because we can not reproduce your environment, ... Your application is very different from the provided in the Nearforums release. 


Kind Regards,