title: EF Core encoding with Firebird 2.5
body: <p>I am migrating a legacy system made in Delphi + FireDac to C# + EF. As it is a legacy system, there is already a database with many records (Many records without encoding information).</p>
  <p>When I get records that contain special characters using C# + EF, the characters are not displayed correctly.</p>
  <p>How can I fix this problem?</p>
  <p><strong>C#</strong></p>
  <p><a href="https://i.stack.imgur.com/k9pnl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k9pnl.png" alt="enter image description here" /></a></p>
  <p><strong>Delphi</strong></p>
  <p><a href="https://i.stack.imgur.com/g1APz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g1APz.png" alt="enter image description here" /></a></p>
  <p><strong>MainWindow.xaml.cs - ButtonClick</strong></p>
  <pre class="lang-cs prettyprint-override"><code>private void Button_Click(object sender, RoutedEventArgs e)
  {
      string appPath = AppContext.BaseDirectory;
      string connectionString = $&quot;database=localhost/3050:{appPath}\\database\\test.fdb;user=sysdba;password=masterkey&quot;;          
      using (AppDbContext con = new AppDbContext(connectionString))
      {
          Product p = con.Products.First();
          lblText.Text = p.Name;                
      }
  }
  </code></pre>
  <p><strong>AppDbContext.cs</strong></p>
  <pre class="lang-cs prettyprint-override"><code>public class AppDbContext : DbContext
  {
      private readonly string _connectionString;
      public DbSet&lt;Product&gt; Products { get; set; }
  
      public AppDbContext(string connectionString)
      {
          _connectionString = connectionString;
      }
  
      protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
      {
          base.OnConfiguring(optionsBuilder);
  
          optionsBuilder.UseFirebird(_connectionString);
      }
  }
  </code></pre>
  <p><strong>Product.cs</strong></p>
  <pre class="lang-cs prettyprint-override"><code>[Table(&quot;PRODUCTS&quot;)]
  public class Product
  {
      [Column(&quot;ID&quot;)]
      public int Id { get; set; }
      [Column(&quot;NAME&quot;)]
      public string Name { get; set; }
  }
  </code></pre>
  <p><a href="https://github.com/ofelipegodinho/SOposts/tree/master/CSharp/EntityFramework/FirebirdEncoding" rel="nofollow noreferrer">Complete C# project code</a></p>