I want to build a WPF app that uses entity framework core so that I can handle SQLite databases.
I then do the following, for instance:
Microsoft.EntityFrameworkCore.Sqlite
and Microsoft.EntityFrameworkCore.Tools
.MainWindow.xaml
and add an event handler to the Click
event such that the xaml looks like:<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">
<Grid>
<Button Click="ButtonBase_OnClick"></Button>
</Grid>
</Window>
MainWindow.xaml.cs
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<Test> Tests { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite("Data Source=local.db");
}
}
public class Test
{
public int Id { get; set; }
}
}
Add-Migration Migration1
Now, if I go to the bin/Debug
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:
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:
.net framework
and .net core
will potentially lead to having duplicate implementations of assemblies referenced directly or indirectly by your application (maybe other modules of my application uses .net framework's
System.Net.Http.dll
classes but EF core or its dependencies references .net core's
System.Net.Http.dll as well)?If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With