title: Deploying a WPF application that uses Entity Framework Core
body: <p>I want to build a WPF app that uses entity framework core so that I can handle SQLite databases.</p>
  
  <p>I then do the following, for instance:</p>
  
  <ul>
  <li>Using Visual Studio 2017 (15.5.2), create a WPF application.</li>
  <li>Open the nuget package manager and install <code>Microsoft.EntityFrameworkCore.Sqlite</code> and <code>Microsoft.EntityFrameworkCore.Tools</code>.</li>
  <li>Drop a button onto my <code>MainWindow.xaml</code> and add an event handler to the <code>Click</code> event such that the xaml looks like:</li>
  </ul>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;Window x:Class="WPFEFCoreDeploymentTest.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          Title="MainWindow" Height="350" Width="525"&gt;
      &lt;Grid&gt;
          &lt;Button Click="ButtonBase_OnClick"&gt;&lt;/Button&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <ul>
  <li>Drop the following code onto the code behind file <code>MainWindow.xaml.cs</code></li>
  </ul>
  
  <pre class="lang-cs prettyprint-override"><code>namespace WPFEFCoreDeploymentTest
  {
      using System.Linq;
      using System.Windows;
      using Microsoft.EntityFrameworkCore;
  
      public partial class MainWindow
      {
          public MainWindow()
          {
              InitializeComponent();
          }
  
          private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
          {
              using (var context = new SomeContext())
              {
                  if (context.Database.GetPendingMigrations().Any())
                  {
                      context.Database.Migrate();
                  }
              }
          }
      }
  
      public class SomeContext : DbContext
      {
          public DbSet&lt;Test&gt; Tests { get; set; }
  
          protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
          {
              optionsBuilder.UseSqlite("Data Source=local.db");
          }
      }
  
      public class Test
      {
          public int Id { get; set; }
      }
  }
  </code></pre>
  
  <ul>
  <li>Use package manager console to create the migration script: <code>Add-Migration Migration1</code></li>
  <li>Build and run the application</li>
  </ul>
  
  <p>Now, if I go to the <code>bin/Debug</code> folder for my project, I notice that there are many DLLs that I assume to be the .NET core's implementation of the .NET standard (maybe I'm just being very stupid), for instance:</p>
  
  <ul>
  <li>System.Collections.Immutable.dll</li>
  <li>System.ComponentModel.Annotations.dll</li>
  <li>System.Data.Common.dll</li>
  <li>System.Net.Http.dll</li>
  <li>the list goes on</li>
  </ul>
  
  <p>So, if I understand correctly, when no redirects are added to the config app.config, these signed assemblies have to be accessible to the executable, meaning if I create an installer, I have to deploy these assemblies along with my application. But .NET framework already implement these, and .NET framework must be installed if someone wants to execute the WPF application on their machines. This makes me wonder:</p>
  
  <ol>
  <li>Can I replace these .net core implementation assemblies with .net framework's implementation? Is it possible? </li>
  <li>If the former point is technically possible, should it work or this may create all sorts of problems?</li>
  <li>If not possible, is it expected that mixing both <code>.net framework</code> and <code>.net core</code> will potentially lead to having duplicate implementations of assemblies referenced directly or indirectly by your application (maybe other modules of my application uses <code>.net framework's</code> <code>System.Net.Http.dll</code> classes but EF core or its dependencies references <code>.net core's</code> System.Net.Http.dll as well)?</li>
  </ol>