BlogEngine.NET configuration for SQLite Providers

This is a quick rundown of the changes required for gettting BlogEngine.NET work with SQLite.

  1. Get log4net (http://logging.apache.org/log4net/) and SQLite ADO.NET Provider (http://sqlite.phxsoftware.com).
  2. Change “blogProvider” to SQLiteBlogProvider
    <BlogEngine>
    <blogProvider defaultProvider="SQLiteBlogProvider">
    <providers>
    <add name="SQLiteBlogProvider" type="BlogEngine.Core.Providers.SQLiteProvider.SQLiteBlogProvider" />
    </providers>
    </blogProvider>
    </BlogEngine>
    
  3. Set role and membership providers to SQLite. Remember that you should set the applicationName as soon as possible (trust me, I got burnt a few times by not doing so).
    <membership defaultProvider="SQLiteMembershipProvider">
    <providers>
    <clear/>
    <!-- <add name="XmlMembershipProvider" type="BlogEngine.Core.Providers.XmlMembershipProvider" description="XML membership provider" xmlFileName="~/App_Data/users.xml"/> -->
    <add name="SQLiteMembershipProvider"
    type="BlogEngine.Core.Providers.SQLiteProvider.SQLiteMembershipProvider"
    applicationName="/Codoxide" />
    </providers>
    </membership>
    <roleManager defaultProvider="SQLiteRoleProvider" enabled="true">
    <providers>
    <!-- <add name="XmlRoleProvider" type="BlogEngine.Core.Providers.XmlRoleProvider" description="XML role provider" xmlFileName="~/App_Data/roles.xml"/> -->
    <add name="SQLiteRoleProvider"
    type="BlogEngine.Core.Providers.SQLiteProvider.SQLiteRoleProvider"
    applicationName="/Codoxide" />
    </providers>
    </roleManager>
    
  4. Setup log4net appender of your choosing.

The above is obviously a very lazy piece of documentation. It’s only there to serve as a guide for you to understand the projects web.config file where you’d find the complete customization requried.

Changes affecting sql.config

I have used the sql.config file that was used by the SQLBlogProvider with few modifications. Firstly, the connectionString attributeĀ  is set to “Data Source={0}\blogengine.db”. The SQLite ADO.net provider requries that the data source contains the full path to the SQLite database. Therefore, the above string is used as the pattern for a string.Format operation where {0} receives the absolute file system path to app_data folder.

You will also notice an additional tag for “BlogEngine_LocalPath”, which contains an absolute path to the SQLite db file. Now, unlike the default XML provider in BE.NET, I’ve been too lazy to include a default user account into the database. So, you’d have to use ASP.NET Web Site Administration Tool to create user accounts. When invoked through the Admin Tool it becomes impossible to use Server.MapPath as the current HTTP Context turns out to be null. The “BlogEngine_LocalPath” element is there to be used in this situation.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

This site uses Akismet to reduce spam. Learn how your comment data is processed.