Once you’ve downloaded the required Simple.Data assemblies, you have the option to store your data store’s connection details in your program’s configuration file. Simple.Data looks for no other information from this file.
You have two options for storing a Simple.Data connection string in a config file.
<configuration> <connectionStrings> <add name="Simple.Data.Properties.Settings.DefaultConnectionString" connectionString="--Your connection string--" /> </connectionStrings> </configuration>
Then you can open this database with the parameterless Open()
method:
var db = Database.Open();
<configuration> <connectionStrings> <add name="MvcMusicStoreDB" connectionString="--Your connection string" /> </connectionStrings> </configuration>
Then you can open this database with the OpenNamedConnection()
method:
var db = Database.OpenNamedConnection("MvcMusicStoreDB");