BlogEngine.NET configuration for SQLite Providers

by Sameera 28. October 2007 15:21

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.

Comments

Add comment


(Will show your Gravatar icon)

biuquote
  • Comment
  • Preview
Loading



About Me

Sameera Perera

Sameera Perera

  • Solutions Architect
  • View Sameera Perera's profile on LinkedIn

Calendar

<<  September 2010  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

View posts in large calendar

Disclaimer

This is a personal blog. The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

All forms of source code published on Codoxide.com are distributed under the Apache License, Version 2.0 unless otherwise stated.
The rest of the content are published under a Creative Commons Attribution 3.0 License.
Creative Commons License