BlogEngine.NET configuration for SQLite Providers
 

by Sameera on October 28, 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
    [code:xml]
       <BlogEngine>
            <blogProvider defaultProvider="SQLiteBlogProvider">
                <providers>
                  <add name="SQLiteBlogProvider" type="BlogEngine.Core.Providers.SQLiteProvider.SQLiteBlogProvider" />
                </providers>
            </blogProvider>
        </BlogEngine>
    [/code]

  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).
    [code:xml]
    <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>
    [/code]

  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.

Add comment


(Will show your Gravatar icon)  

biuquote
  • Comment
  • Preview
Loading



About Me

Sameera Perera

Sameera Perera

Log in

RecentComments

Comment RSS

Calendar

<<  November 2008  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

Archive

Disclaimer

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

© Copyright 2008

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

CodoxideTM

Copyright © 2008  codoxide.com. All rights reserved. Designed by Sameera Perera