实体框架C#插入数据俄语编码问题

实体框架C#插入数据俄语编码问题,c#,mysql,asp.net-mvc,entity-framework,C#,Mysql,Asp.net Mvc,Entity Framework,我在我的项目中使用EDM模型 当我通过post请求在数据库中插入俄语单词时,我会得到????? 控制器: [Authorize] [HttpPost] public string DescEdit(FormCollection formValues) { var CurrentUserPhoto = User.Identity.Name; string x = Request.Form["id"]; Int64 id = Convert.ToInt64(x); p

我在我的项目中使用EDM模型

当我通过post请求在数据库中插入俄语单词时,我会得到
?????

控制器:

[Authorize]
[HttpPost]
public string DescEdit(FormCollection formValues)
{
    var CurrentUserPhoto = User.Identity.Name;
    string x = Request.Form["id"];
    Int64 id = Convert.ToInt64(x);
    photos upPhotoDesc = photosRepository.GetPhotosById(id, CurrentUserPhoto);
    upPhotoDesc.description = Request.Form["value"];
    photosRepository.Save();

    return Request.Form["value"];
}
  • 在数据库中,所有字符集都设置为utf-8
  • 在布局页面中,内容enc类型为utf-8
  • 数据库代码:

    CREATE TABLE `photos` (
      `id` bigint(255) NOT NULL AUTO_INCREMENT,
      `done` tinyint(1) NOT NULL DEFAULT '0',
      `imgsmall` varchar(255) NOT NULL DEFAULT '',
      `imgcrop` varchar(255) NOT NULL DEFAULT '',
      `imgmiddle` varchar(255) NOT NULL DEFAULT '',
      `imgbig` varchar(255) NOT NULL DEFAULT '',
      `full_size` varchar(255) NOT NULL DEFAULT '',
      `description` varchar(255) DEFAULT NULL,
      `name` varchar(255) DEFAULT NULL,
      `permission` tinyint(1) NOT NULL DEFAULT '0',
      `userid` int(11) NOT NULL DEFAULT '0',
      `userlogin` varchar(255) NOT NULL DEFAULT '',
      `rating` smallint(5) DEFAULT '0',
      PRIMARY KEY (`id`),
      KEY `indx_photos_1` (`id`,`userlogin`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_unicode_ci;
    

    charset=utf8
    添加到实体框架的连接字符串
    这是一个工作的添加节点:

    <add name="photostorageEntities"
         connectionString="metadata=res://*/Models.Photos.csdl|res://*/Models.Photos.ssdl|res://*/Models.Photos.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=ServerIP;User Id=UID;password=PASS;Persist Security Info=True;database=photostorage; Charset=utf8&quot;"
         providerName="System.Data.EntityClient" />
    
    
    
    嗯,事件链中的某些东西一定在对过时的字符集进行有损转换。您需要识别那个东西,并确保它使用Unicode。暗中拍摄:您确定数据库实际上包含问号吗?可能只有你用来查看数据库的东西才会显示问号。我已经花了两个小时试图理解这个“东西”在哪里:))你有没有用调试器检查过代码,并确保
    Request.Form[“value”]
    仍然包含正确的西里尔字母?如果您还没有看到它,我最近就PHP/LAMP中常见的字符集问题写了这篇文章,谢谢您的帮助-省去了我的头疼!添加字符集=utf8导致“不支持嵌套事务”错误:(