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.

BlogEngine.NET 1.2 SQLite Edition v0.1

by Sameera 20. October 2007 17:01

Click here to download the project (2.9 MB ZIP file).

Files that were harmed during the makings of BlogEngine.NET 1.2 SQLite Edition Big Grin:

Moved

  • Moved TinyMCE out of Admin folder (which has restircted accesses) to a new Common folder. This was done to fix the problem of simlies being hidden from non-member users.

Added/Deleted

  • None

Modified

  • Take a look at this comprehensive folder comparison report (2.8 MB compressed folder containing folder comparison report in HTML format).

The above files are hosted on my SkyDrive.

Next Up:

There are few configuration steps that you'd need to go through before using BE.NET with SQLite. Hopefully, I'd be able to explain them in my next post. I seem to have messed up the live preview for comments.Oops! I'd have to check that out now.

Synopsis: BlogEngine.NET 1.2 with SQLite - BlogEngine.Core

by Sameera 20. October 2007 07:35

Now that my SQLite Provider implementations seem to be running smoothly enough, it's time I move towards releasing the code.  Before I do, I want to post all the changes that I have made (excluding those are specific to this website's design). To start off here are the changes affecting the BlogEngine.Core library project:

Added

  • AbstractDatabase.cs
    • Path: Providers/
    • Generic base class abstracting database specific implementations
  • Database.cs
    • Path: Providers/SQLiteProvider/
    • Extends AbstractDatabase to provide SQLite specific implementations
  • SQLiteBlogProvider.cs, SQLiteMembershipProvider.cs, SQLiteRoleProvider.cs
    • Path: Providers/SQLiteProvider/
    • Self explanatory

Removed or Modified

  • None.

There is also an additional reference to log4net, used by Membership and Role providers. Original code from Peter A. Bromberg used the Event Log for loggging errors which fails if you are running on a Shared Host machine. Log4Net on the other hand executes without a problem under medium trust scenarios. I have used the File Appender of log4net. You could also easily switch to using SQLite database itself for logging, if that's your preference.

Changes to BlogEngine.Web and the downloadable source code are comming up on the next post... 

SQLite Providers for BlogEngine.net 1.2

by Sameera 12. October 2007 15:14

This is a test run for my SQLite providers for BlogEngine 1.2. This includes, in addition to a SQLite blog-provider, a port of the SQLite Membership and Role providers originally posted by Peter A. Bromberg. While it was quite possible for me to adopt the same code used by MSSqlBlogProvider class and directly integrate the SQLite Membership/Role provider classes, I chose to make some syntatic adjustments to make those classes fit into my own style of coding.

Anyways, this post will follow up with imported posts from my Blogger account. It will give me a chance to test out the code I've written, with some real data.

:fingers-crossed: Cool

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