zoukankan      html  css  js  c++  java
  • How to fix Column 'InvariantName' is constrained to be unique 解决办法!

    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: 

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

  • 相关阅读:
    票房和口碑称霸国庆档,用 Python 爬取猫眼评论区看看电影《我和我的家乡》到底有多牛
    用 Python 写个七夕表白神器
    3. GC复制算法
    一个粗糙的RPC框架设计思路
    503Service Unavailable
    centos 7.8下载地址
    海康摄像头SDK在Linux、windows下的兼容问题(二)已解决
    海康摄像头SDK在Linux、windows下的兼容问题
    二重指针
    【JavaScript 对象03】
  • 原文地址:https://www.cnblogs.com/mschen/p/4595545.html
Copyright © 2011-2022 走看看