Creating Installer supports Entity Framework Core

Viewed 39

I am Trying to Create a release for my WPF project. I am using Entity Framework core with SQL Server using DataContext.

Here is an Instance of my context:

DbContextOptions options = new DbContextOptionsBuilder().UseSqlServer(CONNECTION_STRING).Options;
_context = new CoordinatesContext(options);

I try to release the app using Microsoft Installer and it worked as I excpected... but when I release it to another pc The app is crushing the first time it attaches the Database.

I downloaded msssql localdb to the PC and when I looked on the Event Viewer it throws SQL Exception.

How can I Initialize the Database of the app in another PC? i guess this question is trivial but I Can't find any information about publishing EF Core related app.

1 Answers

You are getting Errors because of Invalid connection string. There are two ways to resolve the issue:

  1. Use sqlite instead of sql Server.
  2. export the database first to your new Pc where you want to install the Application so that there is no difference in the connection strings between your development pc and new client PC.
Related