Earlier this week I blogged about IIS Express, and discussed some of the work we
are doing to make ASP.NET development easier from a Web Server perspective.
In today's blog post I'm going to continue the simplicity theme, and discuss
some of the work we are also doing to enable developers to quickly get going
with database development. In particular, I'm pleased to announce that we've
just completed the engineering work that enables Microsoft's free SQL Server
Compact Edition (SQL CE) database to work within ASP.NET applications. This
enables a light-weight, easy to use, database option that now works great for
ASP.NET web development.
Introducing SQL Server Compact Edition 4
SQL CE is a free, embedded, database engine that enables easy database
storage. We will be releasing the first public beta of SQL CE Version 4 very
shortly. Version 4 has been designed and tested to work within ASP.NET Web
Works with Existing Data APIs
SQL CE works with existing .NET-based data APIs, and supports a SQL Server
compatible query syntax. This means you can use existing data APIs like
ADO.NET, as well as use higher-level ORMs like Entity Framework and NHibernate
with SQL CE. Pretty much any existing data API that supports the ADO.NET
provider model will work with it.
This enables you to use the same data programming skills and data APIs you
No Database Installation Required
SQL CE does not require you to run a setup or install a database
server in order to use it. You can now simply copy the SQL CE binaries into the
\bin directory of your ASP.NET application, and then your web application can
run and use it as a database engine. No setup or extra security permissions are
required for it to run. You do not need to have an administrator account on the
machine. It just works.
Applications you build can redistribute SQL CE as part of them. Just copy
your web application onto any server and it will work.
Database Files are Stored on Disk
SQL CE stores databases as files on disk (within files with a .sdf file
extension). You can store SQL CE database files within the \App_Data folder of
your ASP.NET Web application - they do not need to be registered in order to use
them within your application.
The SQL CE database engine then runs in-memory within your application. When
your application shuts down the database is automatically unloaded.
Shared Web Hosting Scenarios Are Now Supported with SQL
SQL CE 4 can now run in “medium trust” ASP.NET 4 web hosting scenarios –
without a hoster having to install anything. Hosters do not need to
install SQL CE or do anything to their servers to enable it.
This means you can build an ASP.NET Web application that contains your code,
content, and now also a SQL CE database engine and database files – all
contained underneath your application directory. You can now deploy an
application like this simply by using FTP to copy it up to an inexpensive shared
web hosting account – no extra database deployment step or hoster installation
SQL CE will then run within your application at the remote host. Because it
runs in-memory and saves its files to disk you do not need to pay extra for a
SQL Server database.
Visual Studio 2010 and Visual Web Developer 2010 Express
VS 2010 and Visual Web Developer 2010 Express will add SQL CE 4 tooling
support for ASP.NET scenarios in an update we'll be rolling out in the future.
This will enable you to add SQL CE database files to your ASP.NET projects, use
the Visual Studio Server Explorer to create and edit tables in them, and use
higher-level designers like Entity Framework (see below) to model and map the
database to classes that you can then query and program against using LINQ.
This means that in addition to using the same data APIs you know today, you
will also be able to easily use the same development tools you already know with
Supports Both Development and Production
SQL CE can be used for both development scenarios and light-usage production
usage scenarios. With the SQL CE 4 release we've done the engineering work to
ensure that SQL CE won't crash or deadlock when used in a multi-threaded server
scenario (like ASP.NET). This is a big change from previous releases of SQL CE
– which were designed for client-only scenarios and which explicitly blocked
running in web-server environments. Starting with SQL CE 4 you can use it in a
web-server as well.
There are no license restrictions with SQL CE.
Easy Migration to SQL Server
SQL CE is an embedded database – which makes it ideal for development and
light-usage scenarios. For high-volume sites and applications you'll probably
want to migrate it to use SQL Server Express (which is free), SQL Server or SQL
Azure. These servers enable much better scalability, more development features
(including features like Stored Procedures – which aren't supported with SQL
CE), as well as more advanced data management capabilities.
We'll ship migration tools that enable you to optionally take SQL CE
databases and easily upgrade them to use SQL Server Express, SQL Server, or SQL
Azure. You will not need to change your code when upgrading a SQL CE database
to SQL Server or SQL Azure. Our goal is to enable you to be able to simply
change the database connection string in your web.config file and have your
application just work.
SQL CE 4 provides an easy, lightweight database option that you'll now be
able to use with ASP.NET applications. It will enable you to get started on
projects quickly – without having to install a full database on your local
development box. Because it is a compatible subset of the full SQL Server, you
write code against it using the same data APIs (ADO.NET, Entity Framework,
You will be able to easily deploy SQL CE based databases to a remote hosting
account and use it to run light-usage sites and applications. As your site
traffic grows you can then optionally upgrade the database to use SQL Server
Express (which is free), SQL Server or SQL Azure – without having to change your