实体框架4 unicode问题保存

问题描述 投票:2回答:2

我在使用带有MySQL连接器6.3.6的Entity Framework 4时遇到问题。我已经将MySQL dabase设为utf8 - 默认排序规则,以便在我的网站上使用unicode。问题是,当我尝试使用实体框架4保存unicode字符串时,我可以从数据库中读取unicode到我的网站,它会在我的数据库上放置问号。我甚至从Visual Studio设计器设置了Unicode属性但无济于事。我是否遗漏了某些内容,或者您​​需要做些什么来使实体框架将unicode写入数据库?

asp.net mysql asp.net-mvc entity-framework-4
2个回答
4
投票

好的经过大量的研究后发现,MySQL连接器6.3.6得到了一个连接字符串参数'charset = utf8'。您需要将其添加到您的连接字符串。


1
投票

在Web.config文件中使用'charset = utf8'创建连接字符串

<connectionStrings>
<add name="con" connectionString="server=localhost;Uid=root;password=;database=webpro;charset=utf8 "  />    
</connectionStrings>
© www.soinside.com 2019 - 2024. All rights reserved.