-
Notifications
You must be signed in to change notification settings - Fork 24
Using Microsoft SQL Server
MicroLite is built to work with any version of Microsoft SQL Server from 2005 onwards and uses the SqlClient provider supplied with the .NET framework.
Add a named connection string for your Database specifying the provider name. It should look similar to this (note that the provider name is required):
<connectionStrings>
<add name="NorthwindDB"
connectionString="Data Source=localhost;Initial Catalog=Northwind;Persist Security Info=False;Integrated Security=SSPI;"
providerName="System.Data.SqlClient" />
</connectionStrings>
Create a session factory using the ForMsSql2005Connection
or ForMsSql2012Connection
extension method supplying the name of the connection string you added to the app.config/web.config.
using MicroLite;
using MicroLite.Configuration;
static void Main(string[] args)
{
var sessionFactory = Configure
.Fluently()
.ForMsSql2005Connection("NorthwindDB")
.CreateSessionFactory();
...
}
The ForMsSql2005Connection
supports MS SQL Server 2005 onwards, ForMsSql2012Connection
supports MS SQL Server 2012 onwards. Use the version which supports the lowest version of SQL your application will connect to.
MicroLite supports the following Identifier Strategies for MS SQL 2005:
- Assigned
- DbGenerated
In addition it also supports the following Identifier Strategies for MS SQL 2012:
- Sequence