2

I have: MSSQL server and Entity Framework version 6.1.3.

When I try to seed some data in a migration Up() method, I get a broken encoding value in a column.

My Up() method looks like this:

public override void Up()
{
    Sql(@"insert into TableName values ('@fi','ru',N'фи')");
}

I expect that if I put N in front of a value that should be treated as a unicode value I should get 'фи' value in the third column, but what I get is 'ôè'.

Remark

When I execute the same request inside of the Microsoft Sql Server Management Studio I get the expected result. All works correct.

What can be the cause of such a weird encoding twist?

Thanks!

yurart
  • 593
  • 1
  • 6
  • 23
  • Could it be [something like this](http://stackoverflow.com/questions/5889438/entity-framework-c-sharp-insert-data-russian-encoding-problems)? – default Nov 19 '15 at 12:44
  • this may be dependent on your editor encoding ? Have you tried getting the query from a file for which you fully manage encoding ? – tschmit007 Nov 19 '15 at 12:46
  • I write my code in visual studio and yes, I tried to copy request from visual studio and paste it into management studio. And it works. – yurart Nov 19 '15 at 12:51
  • I suppose that guilty one is Entity Framework itself. It produced a file with the wrong encoding. – yurart Nov 19 '15 at 13:24
  • tschmit007, you were right about wrong file encoding. I would be happy to mark your answer as a correct answer. – yurart Nov 19 '15 at 13:26
  • Success had come after I opened the file in Notepad++ then converted it to UTF8 without BOM and then to UTF8 back again. – yurart Nov 19 '15 at 13:45

0 Answers0