I am using EF Code First with migrations for a project and I have stumbled upon a strange behavior:
Executing the “Enable-Migrations”-command in the Package Manager Console generates a “Migrations” folder and “Configurations.cs” file. When I check the encoding of the “Configurations.cs” in Notepad++ it shows that it is ANSI encoded.
When I create an arbitrary file in Visual Studio 2010 it’s always encoded in UTF-8. Why does NuGet generate the file in another encoding?
Thanks in advance,
Chris
I finally got around to properly investigating this…
The files (Configuration.cs and the individual migration files) are actually being saved as UTF-8 without a file signiture. This format is indistinguishable from ANSI unless non-ANSI characters appear somewhere in the file. Tools like Notepad++ will only show it as UTF-8 if there are non-ANSI characters in the file. This is because a UTF-8 file with only ANSI characters is 100% compatible with the ANSI format.
If you have non-ANSI characters in your context type name, table names, etc. things will work as you expect, and Notepad++ will report the file format as UTF-8.