Tristan Trainer
Tristan Trainer

Reputation: 3070

SQLite: How do I set up the Data Source of a connection string to be a file within my application folder?

I am creating an application that needs a database as it's data store. I have installed SQLite in my project (including Entity Framework 6.0.0) as well as the extension SQLite Server Compact ToolBox.

I am trying to create a database in a local file using SQLite but I'm unsure of the format for doing so in the Data Source part of the connection string. This is using a code first approach.

I have looked at 20+ videos and read numerous tutorials online about how to set up databases using Entity Framework over the past couple of months and still am lost about how to set up and run a database from code. I can create the Models and the Context, perform CRUD operations on a database I have created somewhere in my program files (using a default connection string I am guessing), but am still none the wiser about where they are installed and connection strings, specifically Data Source, I want the database to be shipped with the application not requiring a separate install.

Every time I come back to adding a database to my Application I have got frustrated at the lack of clear tutorials on this subject, including one I paid for! So I leave it till later, but it is the last hurdle in my Application so now is 'later'.

Any help would be appreciated!

TLDR: I need to know what the syntax/format is for a Connection Strings Data Source targeting a folder/file within my project using SQLite.

Upvotes: 0

Views: 1056

Answers (1)

Kacper Marcisz
Kacper Marcisz

Reputation: 26

To create connection string simply write

Data Source=NewApp.db

and that's all

Upvotes: 1

Related Questions