title: When using Entity Framework with MySQL, Unicode characters are replaced with basic characters
body: <p><strong>Background</strong></p>
  
  <p>I noticed that when saving data from my MVC website through Entity Framework, if I had something like the Greek "α" it would be converted to "a".</p>
  
  <p><strong>Actions Taken</strong></p>
  
  <p>I overrode <code>OnModelCreating</code> in the database context and added the following code.</p>
  
  <pre><code>modelBuilder.Properties&lt;string&gt;().Configure(x =&gt; { x.HasColumnType("NVARCHAR"); x.IsUnicode(true); });
  </code></pre>
  
  <p>This initially looked promising as the newly generated migration had this structure.</p>
  
  <pre><code>AlterColumn("dbo.Item", "Name", c =&gt; c.String(maxLength: 800, storeType: "nvarchar"));
  </code></pre>
  
  <p>And after running the migration I saw the relevant columns had collation <code>utf8_general_ci</code>.</p>
  
  <p><strong>Persisting Problems</strong></p>
  
  <p>This changed nothing when saving data through my application. When passing Greek characters down from the website it still downgrades to a basic equivalent.</p>
  
  <p>If I try to add these letters directly through MySQL Workbench however, it stores them just fine and the website will display correctly when retrieving the data.</p>
  
  <p><strong>Other Information</strong></p>
  
  <p>Using the database logging code below, I was able to see the SQL Entity Framework is using.</p>
  
  <pre><code>dbContext.Database.Log = s =&gt; System.Diagnostics.Debug.WriteLine(s);
  </code></pre>
  
  <p>The seemingly okay SQL.</p>
  
  <pre><code>SET SESSION sql_mode='ANSI';INSERT INTO `Item`(
  `Name`, 
  `Owner_Id`) VALUES (
  @gp1, 
  @gp2);
  
  -- @gp1: 'The_α_1' (Type = String, IsNullable = false, Size = 7)
  
  -- @gp2: '7a897e05-cc87-410b-bc80-70c75abae95b' (Type = String, IsNullable = false, Size = 36)
  </code></pre>
  
  <p>Any ideas? Thanks for any help.</p>