1

I've built a Windows Form App project and now I wanna create a setup which is going to be used all computer. I published my project, and after I had clicked my exe, it's not working. I'm taking a error message like below.

error picture

error is going on like System.Data.DataException:

System.Data.DataException: An exception occurred while initializing the database. See the InnerException for details. ---> System.Data.Entity.Core.EntityException: The underlying provider failed on Open. ---> System.Data.SqlClient.SqlException: Cannot attach the file 'C:\Users...

My way:

1- I am using localDb in app-config file, so I've organized conection string for it.

2- I put myDb.mdf into my project, after I'd set its "restrict address" for single-user and I'd detached.

3.I published my project.

<connectionStrings>
   <add name="DatabaseContext" connectionString="Server=DESKTOP-N01M7RV;Database=DB_GOPCBS;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
</connectionStrings>
ssilas777
  • 9,672
  • 4
  • 45
  • 68
benna121
  • 11
  • 2
  • Not familiar with this in detail. [Here is one hack](https://stackoverflow.com/questions/23048481/system-data-entityexception-the-underlying-provider-failed-on-open). Try that to see if you get a heartbeat. I have this large [application launch checklist here](https://stackoverflow.com/questions/53512998/desktop-applicaton-not-opening-after-installation-in-client-system/53530377#53530377). Does Entity require any runtimes? Very typical to lack a runtime such as .NET, Java, VC/C++ runtime, etc... Or lacking permissions. [Short check list here](https://stackoverflow.com/a/56500151/129130). – Stein Åsmul Aug 28 '19 at 12:55

0 Answers0