如何解决"指定键太长;最大密钥长度为1000字节" [英] How do i fix "Specified key was too long; max key length is 1000 bytes"

查看:704
本文介绍了如何解决"指定键太长;最大密钥长度为1000字节"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到指定的键过长,最大密钥长度为1000字节我的服务器上。我有以下(如果我错过了一个标签它只是可怜的复制和粘贴。

I am getting "Specified key was too long; max key length is 1000 bytes" on my server. I have the following (if i miss off a tag its just poor copy and paste.

<configuration>
  <configSections>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=xxxxx" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="ArticleContext" providerName="MySql.Data.MySqlClient" connectionString="server=xxxxxxxx; Port=xxxx; database=xxxxxx; User Id=xxxxxx; Pwd=xxxxx" />
</connectionStrings>

  <system.web>
<httpRuntime targetFramework="4.5" />
    </system.web>

 <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">

和进一步回落

<entityFramework>
    <contexts>
      <context type="EverythingASP.DAL.ArticleContext, EverythingASP">
        <databaseInitializer type="EverythingASP.DAL.Initializer, EverythingASP" />
      </context>
    </contexts>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
      <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d">
      </provider>
    </providers>
  </entityFramework>
<system.data>
    <DbProviderFactories>
      <remove invariant="MySql.Data.MySqlClient" />
      <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.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  </system.data>

任何想法要寻找什么?我甚至不知道它指的是什么键。当谷歌搜索的唯一答案是有关于迁移的,我没有任何在这个据我所知。

Any ideas what to look for? I dont even know what key it's referring to. When googling the only answers were with regards to migrations, and I don't have any in this as far as I'm aware.

更新#1

所有的实体都在创建时,IDS自动分配EF。这个错误是坚持在启动!该ID是我作为实体的所有定义的:

All entities have Ids assigned automatically by EF when they are created. This error is persisting on startup! The ids are all defined for the entities I have as:

[Key]
public int Id { get; set; }

因此​​,在运行时最大键值为28 ...

So at run-time the max key value is 28...

这是与EF6和mysql的问题吗?

Is this an issue with EF6 and mysql ?

推荐答案

答案是从改变的MyISAM存储引擎为InnoDB。这可以通过脚本来完成,或者如果你正在使用GoDaddy,走在每个表和theres在列的按钮。不支持铃声,他们甚至不知道它是什么。

The answer was to change the storage engine from myisam to innodb. This can be done in script, or if you are using godaddy, go on each of the tables and theres a button in the columns. dont ring support, they dont even know what it is.

这篇关于如何解决&QUOT;指定键太长;最大密钥长度为1000字节&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆