Moosa Arbeed

Moosa Arbeed

  • NA
  • 38
  • 2.4k

How to deploy a WinForm + database + EF6

Nov 30 2019 6:51 AM
I just finished building a C# Windows Form (WinForm) application using Entity Framework 6 database first model, and after publishing it using Microsoft Visual Studio Installer projects, I have realized that the database has not been added to the application.
 
How can I attach the database along with the .EXE file? I have selected the needed prerequisites (.NET Framework and SQL Server Express).
 
I am using Entity Framework 6 (EF6) and my database has a username and password (SQL Server authentication).
 
I have already included the .mdf file in the project and in the output directory.
 
I have tried the solution here: https://stackoverflow.com/questions/32956142/how-to-deploy-application-with-sql-server-database-on-clients

and here: https://stackoverflow.com/questions/25836156/how-to-deploy-sql-server-express-ef-application

I have also tried to use SQL(localDB) instead of SQL Server Express, but it throws the same exception.
 
check the attached images below:
 
 
 
 

Answers (2)