Introduction
When you build a Web project this uses Enterprise Library Community for the application Data Block and the MySQL. Net/co Nnector, VisualStudio throws the error "Column ' InvariantName ' is constrained-be unique. Value ' MySql.Data.MySqlClient ' is already present ", but you added it only once.
is very simple to fix, you need to add "to <remove invariant="MySql.Data.MySqlClient"></remove>
the start of System.Data > DbProviderFactories node.
Background
You can be confused if you used the XML transform for Web. config, Web.Debug.Config or Web.Release.Config.
But you shouldn ' t focus on that. The problem is the provider's installation put in Machine.config the Childnode and <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient"
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 inva Riant 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 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 fromMachin E.config.
Using the Code
Your XML block must is like this to solve the problem:
Hide Copy Code
<system.data> <DbProviderFactories> <remove invariant="MySql.Data.MySqlClient" ></remove> <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=". Net Framework Data Provider for MySQL" type="
Remember to add at the <remove invariant="MySql.Data.MySqlClient"></remove>
start of dbproviderfactories.
How to fix Column ' invariantname ' was constrained to be unique solution!