Okay I dont know why I didn't got any answers yet. Was really trying to fix this issue and finally found the solution.
On your Database global configuration file that you have created within your project to manage all your database related work like add, delete, update and connection. For a local database define a LocalDbPath like this:
public string LocalDBPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
Then use the same LocalDBPath
everywhere in your database connection.
While deploying the project via Setup and Deployment go to:
File System Editor
- Right Click on
File System on Target Machine
- Select
Add Special Folder
- Select
User's Application Data Folder
- And Add your Database file by going into
User's Application Data Folder
-> Right ClickAdd
->File
and choose the file.
Build your solution and you are good to go. Cheers!