This project is read-only.

How to use SQL CE with BE 2.0 inside WebMatrix

Topics: ASP.NET 2.0
Dec 31, 2010 at 1:04 AM
Edited Dec 31, 2010 at 1:11 AM


I have downloaded Microsoft WebMatrix Beta 3 version and the BlogEngine.NET 2.0 version from codeplex.

Inside, Webmatrix console, I selected the option "Site from existing folder" and then pointed it to the "BlogEngine.Web" folder on my disk.

I see that there is a default SQL database called "BlogEngine" listed in the databases section in WebMatrix.

How do i remove this database? Or if thats now allowed, how to configure BE 2.0 to use the SQL CE database to store posts and comments ?

I created a new databse (SQL CE) "BlogEngine.Web.sdf" from within webmatrix. Now where should I enter the info about this database?

Also, If i want to publish this application in my site under folder, what setting do i need to change in Web.Config?

Dec 31, 2010 at 1:14 AM

If you read the read me file inside of the setup folder for SQL_CE it will explain exactly how do use BE with SQP_CE, I am using it and it is great.  All the work is done for you, you do not need to setup anything.

Dec 31, 2010 at 1:32 AM

Jeremy, Thanks for the reply

Are you talking about this file C:\Program Files\Microsoft SQL Server Compact Edition\v4.0\ReadmeSSCE_ENU.htm

I just looked at it, and it didn't mention hwo to configure BE 2.0 with SQL CE 4.0.  Am i looking at the wrong file?


Dec 31, 2010 at 2:31 AM


Running BlogEngine.NET using SQL CE 4.0
If you wish to use SQL CE to store all your blog data, this folder has all the information you'll likely need.

ASP.NET Runtime Requirement for SQL CE 4.0-----------------------------------------------------------ASP.NET 4.0- or -ASP.NET 3.5 with Full Trust- or -ASP.NET 3.5 Medium Trust if web hoster has made configuration changes to allow SQL CE 4.0 to run.

SQL CE 4.0 .SDF File-----------------------------------------------------------The SQL CE .SDF file was created under the SQL CE version 4.0.8435.1 engine.  Although version 4.0.8435.1 is a CTP version of SQL CE 4.0, this .SDF file should work with the final release of SQL CE 4.0.  If there are any compability issues, we will update the .SDF file to work with the final release.  The BlogEngine.sql file is for reference, but not needed to run SQL CE with BlogEngine.NET.  Only the .SDF file is needed.
The .SDF file is already configured with the necessary tables and initial data setup.

Sample Web.config files-----------------------------------------------------------There are 2 sample web.config files in this folder. (1) SQL_CE_for_ASP.NET_4.0_Web.Config (2) SQL_CE_for_ASP.NET_3.5_Web.Config
If your website runs in a ASP.NET 3.5 environment, please review the "ASP.NET Runtime Requirement" above.

Instructions for New Setup-----------------------------------------------------------1. When running BlogEngine.NET under SQL CE 4.0, you will either need SQL CE 4.0 installed on your computer, or if deploying to a webhost, you can simply copy the SQL CE 4.0 binary (DLL) files to your /BIN directory.  The DLL files will be located in the installation folder for SQL CE 4.0.  The installation folder is located at:
%ProgramFiles(x86)%\Microsoft SQL Server Compact Edition\v4.0\Private
If you do not have SQL CE 4.0 installed on your computer, or you need the DLL files, the latest CTP version of SQL CE 4.0 can be downloaded at:
However, please check for the latest version of SQL CE 4.0 before downloading the one at the above link.
2. Copy the following files/folders to your /BIN directory.  The files are located in the SQL CE 4.0 installation folder:
%ProgramFiles(x86)%\Microsoft SQL Server Compact Edition\v4.0\Private
 (a) Copy the file "System.Data.SqlServerCe.dll" into your /BIN directory. (b) There are two sub-folders: AMD64 and X86.  Copy both folders to your /BIN directory.
After copying these files and folders, your /BIN directory will look like this:
/bin   System.Data.SqlServerCe.dll/bin/x86   sqlceca40.dll    sqlcecompact40.dll    sqlceer40EN.dll    sqlceme40.dll    sqlceqp40.dll    sqlcese40.dll /bin/amd64    sqlceca40.dll    sqlcecompact40.dll    sqlceer40EN.dll    sqlceme40.dll    sqlceqp40.dll    sqlcese40.dll 
3. Rename the correct sample web.config file above to web.config and copy it to your blog's root folder.  (This will overwrite your existing web.config file.  If this is not a new installation, make sure you have a backup.)4. Copy the BlogEngine.sdf file into the App_Data folder.5. Surf out to your Blog and see the welcome post.6. Login with the username admin and password admin.  Change the password.

Troubleshooting-----------------------------------------------------------If you use one of the sample web.config files, are running your site on your own machine or a server that SQL CE 4.0 is already installed on, and you receive the following error message when starting the site:
"Failed to find or load the registered .Net Framework Data Provider."
In this scenario, you may need to remove the <> section out of the web.config file.

Dec 31, 2010 at 7:13 AM

To add onto what Jerry has said, BE includes a "setup" folder.  Under that is a folder named "SQL_CE".  In that folder is a ReadMe.txt file that explains how to get started with SQL CE for BE.  Also in that folder is a BlogEngine.sdf file that already has all the tables, columns and initial data already created.  So you don't need to actually create your own SDF file.

Feb 11, 2011 at 12:29 PM
Edited Feb 11, 2011 at 12:30 PM

I see the content is stored as ntext. What about size limitations of the SQL CE? Isn't it a problem? Isn't it too easy to exceed 8k row size? I am considering to run BE on SQL CE but I am afraid of these limitations. Thus I would like to know opinions of those who have already some experience.



Feb 11, 2011 at 2:14 PM

I use BE 2.0 with SQL_CE and have about 600 users/members  on our hiking club website and it works great without any issues at all so far.