Using VistaDB Express as your BlogEngine.NET back end

VDBLOGO-Small It is a day later than I had hoped, but I now have my blog running with a VistaDB back end.  I'm thrilled. I've never been a huge fan of putting my personal blog data in SQL Server and I feel free.

I had never intended to move my data to VistaDB Express when I started work for this presentation a few weeks ago, but after working with it for a while and making the providers, I realized I really wanted to use it for my data storage.  VistaDB has a lot going for it as it is managed code, runs in medium trust, runs on mono and is very lightweight.  I'm really most pleased with the xcopy deployment and the nice graphical management tool.  I have heard from others that speed might be an issue, but it seems fine with the small tests I've run.  Inside BlogEngine with the caching we do, I don't see it as an issue.

As I was making some small changes to the code to make it more secure and getting it ready to make available, I decided to go for it.  I fired up my rough migration tool, made a few small changes, and I had a complete copy of my blog posts, pages, comments, settings, and other stuff in a VistaDB database.  I had to manually add my user name in, but since I'm single user it was no big deal.  My small blog database is less than 1 MB and even easier to copy around than a few directories full of XML files.

If you are interested in playing around with it, or following in my footsteps to using VistaDB Express for your blog data, I'm making it all available now.  Complete with instructions.  If you wish to use it, you are required to meet the license agreement of VistaDB Express which states that it is for non-commercial use.  (If you are a commercial operation, you can purchase VistaDB and then use it with BlogEngine without restriction.)

  • Download this file: BlogEngine131VistaDB33.zip
  • Unzip the file and place the 2 dll files in your blog's bin folder.  (Note: one is the VistaDB Express dll and one is the BlogEngine VistaDB providers.)
  • Place the BlogEngine.* files in your blog's App_Data folder.  These 2 files are your initial VistaDB database.
  • Make changes to your web.config to let BlogEngine know to use VistaDB.  I've included samples of the relevant areas below.
  • As per the VistaDB Express license, you should place a link back to VistaDB somewhere on your blog.  (I placed mine in my footer.)

 

Near the top of your web.config

[code:xml]

<BlogEngine>
    <blogProvider defaultProvider="VistaDBBlogProvider">
      <providers>
        <add name="XmlBlogProvider"
             type="BlogEngine.Core.Providers.XmlBlogProvider, BlogEngine.Core"/>
        <add name="MSSQLBlogProvider"
             type="BlogEngine.Core.Providers.MSSQLBlogProvider, BlogEngine.Core"/>
        <add name="VistaDBBlogProvider"
             type="BlogEngine.Core.Providers.VistaDBBlogProvider, BlogEngine.VistaDB"
             dataSource="~/App_Data/BlogEngine.vdb3"
             password="" />
      </providers>
    </blogProvider>
</BlogEngine>

[/code]


Down under system.web

[code:xml]

 <membership defaultProvider="VistaDBMembershipProvider" >
   <providers>
     <clear />
     <add name="XmlMembershipProvider"
          type="BlogEngine.Core.Providers.XmlMembershipProvider, BlogEngine.Core"
          description="XML membership provider"
          xmlFileName="~/App_Data/users.xml"/>
     <add name="VistaDBMembershipProvider"
          type="BlogEngine.Core.Providers.VistaDBMembershipProvider, BlogEngine.VistaDB"
          dataSource="~/App_Data/BlogEngine.vdb3"
          password="" />
   </providers>
 </membership>

 <roleManager defaultProvider="VistaDBRoleProvider"
              enabled="true"
              cacheRolesInCookie="true"
              cookieName=".BLOGENGINEROLES">
   <providers>
     <clear />
     <add name="XmlRoleProvider"
          type="BlogEngine.Core.Providers.XmlRoleProvider, BlogEngine.Core"
          description="XML role provider"
          xmlFileName="~/App_Data/roles.xml"/>
     <add name="VistaDBRoleProvider"
          type="BlogEngine.Core.Providers.VistaDBRoleProvider, BlogEngine.VistaDB"
          dataSource="~/App_Data/BlogEngine.vdb3"
          password="" />
   </providers>
 </roleManager>
 

[/code]

That is it.  If you are interested in checking out the VistaDB database or want to encrypt the database with a password, you can download VistaDB Express.  (User passwords are encrypted inside the database in the User table, but you can encrypt the whole file if you'd like.)  The initial database has the default settings and the initial welcome post you come to expect.