To open a SQL Server database:
var db = Database.OpenConnection("data source=.;initial catalog=Xyz;etc");
To open a SQL Server Compact Edition 4.0 database:
var db = Database.OpenFile("mydb.sdf");
You can specify a database for Simple.Data in the connectionStrings section of the config file:
<connectionStrings> <add name="Simple.Data.Properties.Settings.DefaultConnectionString" connectionString="data source=.;initial catalog=Simple;integrated security=true" providerName="System.Data.SqlClient" /> </connectionStrings>
Then you can open this database with the parameterless Open method:
var db = Database.Open();
or use a single instance provided as default:
Database.Default.Users.FindById(1);
Simple.Data holds no open connections to the database, so you can keep the db object returned from the Open methods hanging around without worrying.
There was an error while loading. Please reload this page.