0

I'm trying to add a database to a C# Windows Form application using Entity Framework 6 database first model. When I publish it using Microsoft Visual Studio Installer projects the database is not attached to the application.

How can I deploy an .mdf database along with the application executable?

attached DB and connection string

exception thrown

  • 1
    First you have to understand windows form application need database same as your development env that mean you have to install sql express or set an server if more client. either can use Sql light database which is not required any databse setup. https://www.c-sharpcorner.com/UploadFile/5d065a/how-to-use-and-connect-sqlite-in-a-window-application/ – Dharmeshsharma Nov 30 '19 at 09:14
  • 1
    Second SQL files like .mdf check the path where your application can access as development env working like some folder name or AppData something like – Dharmeshsharma Nov 30 '19 at 09:17
  • understood nothing, please clarify your answer and take a look again at the question and at the pictures attached. –  Nov 30 '19 at 10:02
  • Hi Sam313 and welcome to Stack Overflow! I've edited your answer to make it more concise and to make the images visible. I've also edited the title to put the actual error. Please consider including the text of the exception and the connection string, not the image. This will make even easier to find and understand your question for everyone. – Giulio Caccin Dec 01 '19 at 06:56
  • @Sam313 parte of the review process is to give new users suggestion on how to rephrase questions. On meta you can find useful insights on this process https://meta.stackoverflow.com/questions/287466/help-improve-the-help-improvement-queue please if possible add text of exception an connection string – Giulio Caccin Dec 01 '19 at 10:12
  • bro, when you have edited the question you have mixed the whole idea, I have already attached the .mdf file, and the database is already exists with the app and the title is not related to the main problem, I know exactly what I have asked, anyway read the edited question again and you will find out that it is mixed upside down. –  Dec 01 '19 at 12:27
  • The exception is because you've edited the generated context class. It's not related to the deployment process. – Gert Arnold Dec 01 '19 at 12:52

0 Answers0