When you build a web project that uses Enterprise Library Community for the Application Data Block and the MySQL .NET / Connector, VisualStudio throws the error "Column 'InvariantName' is constrained to be unique. Value 'MySql.Data.MySqlClient' is already present", but you added it only once.
Is very simple to fix, you need to add "
<remove invariant="MySql.Data.MySqlClient"></remove>" to the start of system.data > DbProviderFactories node.
You can be confused if you used XML transform for Web.Config, Web.Debug.Config or Web.Release.Config.
But you shouldn't focus in that. The problem is the provider's installation put in machine.config the childNode
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" and normally you put the same manually in your web.config file. So at the compiling time, when web.config heritates maching.config, it results in duplicate "add" child with the same invariant attribute, with the value "MySql.Data.MySqlClient" .
The examples of use around Internet and the tutorials of ELContrib Application Data Block add the DbProviderFactories node to
System.Data element. It suposes that the MySQL .NET/Connector aren't installed in system. It suposes the mysql.data.dll is referenced in any directory and the configuration isn't heritated from machine.config.
Using the code
Your XML block must be like this to solve the problem:
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=220.127.116.11, Culture=neutral" />
Remember to add
<remove invariant="MySql.Data.MySqlClient"></remove> at the start of DbProviderFactories.
I'm developer fall in love with C#, .NET and Mono.
Designing and programming websites since 2001.
I like literature (to read and to write), playing football (soccer)... and of course I'm great fan of La Roja (Spain football team)
At now I work in GetMeAnApartment, I do Research and Development features to upgrade our website (asp.net, MVC, MySQL) and business model (rental short stay apartments)
TECHNOLOGIES: asp.net, asp.net mvc, php, flash, GTK#
APPLICATIONS: wordpress, wikimedia, I programmed modules for Macromedia Flash MX for myself
FRAMEWORKS: .Net Framework, Mono
SERVERS: IIS, apache2
SO: Windows, Debian
SOFTWARE: Visual Studio 2010, 2008. Monodevelop. Glade. Illustrator. Indesign. Photoshop. Dreamweaver.
IT Director and website developer, 2010 - present
Círculo Rojo Publicidad y Comunicación
IT Director and websites developer, 2007 - 2010
Co-founder,Programmer and Developer, Graphical designer 2006 - 2007
Costa Mediterránea Comunicación
Chief writer, 2004 - 2006
Web designer and developer, 2001 - 2003
Designer and Programmer, 2001 - present
Jaime I, University
Advertising, 2000 - 2005