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. hdu-4418-Time travel-高斯+概率dp

    把N个点先转化为2*N-2个点. 比方说把012345转化成0123454321. 这样,就能够找出随意两两个点之间的关系. 然后依据关系能够得出来一个一元多项式的矩阵. 然后就用高斯消元求出矩阵就可 ...

  2. sql server2012附加的数据库问题

    watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMjM2NzUxMw==/font/5a6L5L2T/fontsize/400/fill/I0JBQk ...

  3. cocos2dx的模板容器简单使用(Vector,Map,Value)

    在cocos2dxv3.0beta之前存在顺序性容器cocos2d::CCArray,和cocos2d::CCDictionary.可是在新版本号之后这两个容器都将被cocos2d::Vector&l ...

  4. PHP实现快速排序算法

    快速排序(Quick Sort)是对冒泡排序的一种改进,属不稳定排序算法,由东尼·霍尔在1962年提出.快速排序基本步骤:从数列中挑出一个元素(一般称为称为“基准”),通过一趟排序将要排序的数据分割成 ...

  5. mongoDB 查询附近的人的语句

    mongoDB 自带LBS查询附近的人 {"location":{ $nearSphere: { $geometry: { type : "Point", co ...

  6. SQLServer2012 分页语句执行分析

    上一篇文章提到了,SQLServer2012在使用Offset,Fetch语句分页时,获取了大量不需要的数据,导致查询效率低的问题. 现在让我们来看看,究竟是什么导致SQLServer不能按需取数呢? ...

  7. Study note for Continuous Probability Distributions

    Basics of Probability Probability density function (pdf). Let X be a continuous random variable. The ...

  8. Spring中Quartz动态设置cronExpression

    字段 允许值 允许的特殊字符 秒 0-59 , - * / 分 0-59 , - * / 小时 0-23 , - * / 日期 1-31 , - * ? / L W C 月份 1-12 或者 JAN- ...

  9. 一个css和js结合的下拉菜单,支持主流浏览器

    首先声明: 本人尽管在web前端岗位干了好多年,但无奈岗位对技术要求不高.html,css用的比較多,JavaScript自己原创的非常少,基本都是copy改动,所以自己真正动手写时,发现基础非常不坚 ...

  10. sscanf,sscanf_s及其相关使用方法

    #include<stdio.h> 定义函数 int sscanf (const char *str,const char * format,........); 函数说明   sscan ...