i am a absolute beginner... and it is my first database based application.
i would like to drop a c# wpf application with database (2 tables) on an offline single-user-client. its a wpf c# ef6 code first app. on my machine with vs2019 it runs as intended. now trying to run it on a new set up win10 machine it doesnt even start.
Here is the connectionString for my db:
<connectionStrings>
<add name="ZuschnittverwaltungDB" connectionString="data source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|Datadirectory|\ZuschnittverwaltungDB.mdf;initial catalog=Zuschnittverwaltung.ZuschnittverwaltungDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />
i assume that i am missing a big point but i cant find any solution after searching several days...
Edit1:
AttachDbFilename=|Datadirectory|\ZuschnittverwaltungDB.mdf ->
AppDomain.CurrentDomain.SetData("DataDirectory", Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));
i am thankfully for every approach.
LocalDB is required to be installed separately on the client machine.
If you want to "drop" deploy your database along with the application itself you should use a self-contained database like SQLite.
If you choose to stick with using LocalDB, you need to ensure that your database file is deployed to |Datadirectory|\ZuschnittverwaltungDB.mdf
(or whatever path you have specified in the configuration file) on the target machine.