Introduction

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.

Background

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 frommachine.config.

Using the code

Your XML block must be 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="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.2.4.0, Culture=neutral" />
</DbProviderFactories>
</system.data>

Remember to add <remove invariant="MySql.Data.MySqlClient"></remove> at the start of DbProviderFactories.

How to fix Column 'InvariantName' is constrained to be unique 解决办法!的更多相关文章

  1. navicat连接PostgreSQL报:column “rolcatupdate” does not exist ...错误的解决办法

    avicat premium 连接PostgreSQL出现: column “rolcatupdate” does not exist ... 错误如图: 解决方案: 看看你的navicat 是否为最 ...

  2. Java开发问题:Column 'AAA' in where clause is ambiguous解决办法

    当在java开发中遇到了Column 'AAA' in where clause is ambiguous问题时, 你需要去看看:多表查询的时候不同的表是否出现了相同名称相同的列, 如果存在,你需要在 ...

  3. Incorrect integer value: '' for column 'id' at row 1 错误解决办法

    最近一个项目,在本地php环境里一切正常,ftp上传到虚拟空间后,当执行更新操作(我的目的是为了设置id为空)set id=‘’时提示: Incorrect integer value: '' for ...

  4. Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path 解决办法

    返回数据解析错误 com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT ...

  5. 使flex-direction: column的子元素height: 100%生效的办法

    在flex-direction: column子元素里直接使用height:100%,height并不会被设置成100% <!DOCTYPE html> <html lang=&qu ...

  6. idea中Entity实体中报错:cannot resolve column/table/...解决办法。

    idea中Entity实体中报错:cannot resolve column/table/...解决办法. 若idea中Entity实体中报错: cannot resolve column.... c ...

  7. 操作MySQL出错提示“BLOB/TEXT column request_data in key specification without a key length”解决办法

    错误原因: 查阅资料后才知道,原来Mysql数据库对于BLOB/TEXT这样类型的数据结构只能索引前N个字符.所以这样的数据类型不能作为主键,也不能是UNIQUE的.所以要换成VARCHAR,但是VA ...

  8. SQLite无法使用drop column删除表字段解决办法

    由于项目需求变更,我需要在sqlite数据库的表中删除一个字段,通用的sql操作语句如下: alter table record drop column name; 结果数据库提示如下错误: 搜索得知 ...

  9. 使用JdbcTemplate报 Incorrect column count: expected 1, actual 5错误解决

    Incorrect column count: expected 1, actual 5 在使用jdbc的querForObject queryForList的时候,出现Incorrect colum ...

随机推荐

  1. Oracle Enterprise Manager Cloud Control 12c R4 安装配置

    准备软件 em12.1.0.4_linux64_V45344-01.zip em12.1.0.4_linux64_V45345-01.zip em12.1.0.4_linux64_V45346-01. ...

  2. C++教材

    C++语言: 1.<Essential C++>:Stanley B.Lipman著. 旁枝暂略,主攻核心,轻薄短小.附习题与解答,适合刚開始学习的人. 2.<The C++ Pro ...

  3. windows 7多点触摸开发

    win7 触摸屏系统应用广泛,软件操作方便,功能强大,现以被很多硬件厂商应用. 我曾用一台装有win7 的汉王平板电脑进行了多点触摸软件的开发.      开发环境及条件: 1. 平板电脑+ win7 ...

  4. linux根据部署jenkins

    1. Jenkins 下载 Jenkins 下载网址:http://jenkins-ci.org/ 2. Jenkins 安装 (1) 安装JDK JDK下载:http://www.oracle.co ...

  5. selenium让人摸不着头脑的问题

    selenium让人摸不着头脑的问题 问题一 使用webdriver驱动firefox浏览器时如果不设置参数,默认使用的Firefox的profile和平时打开浏览器使用的firefox不一样,如果要 ...

  6. DataTable数据转换为实体

    我们在用三层架构编写软件时,常常会遇到例如以下问题,就是三层之间的參数传递问题:假设我们在D层查询出数据是DataTable类型的,那么我们在B层甚至U层使用这条数据时,就要用DataTable类型来 ...

  7. js使用栈来实现10进制转8进制 js取除数 余数

    function ten2eight(x){ var s=[]; var r=''; while(x>0){ s.push(x%8); x=parseInt(x/8); } while(s.le ...

  8. 从SAE又回到BAE,感觉好轻松

    [前言] 我这个人总喜欢对同一类东西比較过来比較过去,用过来用过去. 比如曾经选择浏览器,从開始ie,到遨游,世界之窗.qq等等,用了有10款左右的浏览器,每款都用了不短时间, 终于固定在火狐+chr ...

  9. Objective-c 中的算术函数和常数的表示

    常数 常数名 说明 M_PI 圆周率(=π) M_PI_2 圆周率的1/2(=π/2) M_PI_4 圆周率的1/4(=π/4) M_1_PI =1/π M_2_PI =2/π M_E =e M_LO ...

  10. HDU - 2825 Wireless Password(AC自己主动机+DP)

    Description Liyuan lives in a old apartment. One day, he suddenly found that there was a wireless ne ...