I have a ASP.NET Core 1.0 project with EF7. When I add a migration with SQL command and latin characters, I get them replaced by "?" when updating database.
Let's see an example:
public partial class TestEncodingMigration : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(@"some text with latin chars : á é à ñ");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
And this is the script I get from that migration:
PM> dnx ef migrations script <some prev migration> -c MyDbContext
some text with accent: ? ? ? ?
;
GO
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20160216162901_TestEncodingMigration', N'7.0.0-rc1-16348');
As you can see, all latin characters have been replaced by "?"
I had the same problem and I solved it by saving migration file again with UTF-8 encoding.
It seems that add-migration creates files with ANSI encoding.
So, open migration *.cs in notepad and then File->Save As and at the bottom set Encoding to UTF-8 then overwrite.