【问题标题】:MySQL connector v.6.3.6 problem with GUID type in .NET.NET 中 GUID 类型的 MySQL 连接器 v.6.3.6 问题
【发布时间】:2011-05-26 23:59:43
【问题描述】:

我在 mysql (binary 16) 中有一个标识符为 GUID 的表。 要执行 CRUD 操作,我使用安装 mysql 连接器 v.6.3.6 附带的 EF 驱动程序。 尝试通过 EF 插入新对象时,失败并出现错误 {"Data too long for column 'MyIdentifierColumnId' at row 1"}

MyIdentifierColumnId二进制 16 并在 .NET 中翻译为 GUID。所以长度应该不是问题。

有什么提示吗?

【问题讨论】:

    标签: c# .net mysql entity-framework guid


    【解决方案1】:

    根据http://dev.mysql.com/doc/refman/5.1/en/connector-net-connection-options.html 定义为 binary(16) 或 char(36) 的列被视为旧 guid。在新版本中引入了 UUID,如果我们想在连接字符串中使用 Old Guids=true。

    【讨论】:

      【解决方案2】:

      您的回答很有帮助,谢谢。但是我在添加这个“Old Guids = true”时遇到了问题,我不知道如何以及在哪里添加它,我的连接失败了。因此,拥有这段代码可能对其他人有所帮助:

       string connectionString;
       connectionString = "SERVER=" + server + ";" + "DATABASE=" +
       database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";Old Guids=true;";
      
       connection = new MySqlConnection(connectionString);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-04-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多