How to fix Column ' invariantname ' are constrained to be unique solution!

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.