Configuring MicroLite

One of the principles behind the MicroLite framework is that it should be as simple as possible to configure.

There are only 2 things you need to do to configure MicroLite, the first is to add a named connection string to the app.config (or web.config).

    <add name="NorthwindDB"
         connectionString="Data Source=localhost;Initial Catalog=Northwind;Persist Security Info=False;Integrated Security=SSPI;"
         providerName="System.Data.SqlClient" />

Then, in your application start-up you need to call the configuration class to create the session factory for the database you wish to use.

using MicroLite;
using MicroLite.Configuration;

static void Main(string[] args)
    var sessionFactory = Configure
        .ForConnection("NorthwindDB") // The name provided here should match the name in the app.config


Once you have created a session factory, you can either store it in a static property which makes it visible to your application, or ideally register it in an IOC container.

This article was written for version 1.2.2 of the MicroLite framework.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s