.NET Framework 4 Now Supports LocalDB
Microsoft has added LocalDB support in .NET Framework 4. LocalDB is a free developer edition of SQL Server “Denali” meant to provide most of the server’s API but without management overhead.
Microsoft has released an update to the .NET runtime, Update 4.0.2, including a number of improvements related to SQL Server connectivity such as AlwaysOn and LocalDB support in SQLClient. Developers can now access LocalDB instances from Visual Studio, helping them develop and test programs against a simple and easy to maintain SQL database.
Microsoft has made available SQL Server Express, a free and limited edition of their database server, which can be used to test the server and applications using it. But SQL Express has had some installation and administration overhead. Also, keeping up with other SQL Server editions meant making it larger and even harder to work with in small development environments such as one provided by a laptop. So Microsoft decided to introduce a new dedicated version shortly called LocalDB in SQL Server 2012 codename “Denali”.
To access LocalDB the developer needs to provide the connection string "Data Source=(localdb)\v11.0;Integrated Security=true" and the data provider will start a LocalDB instance as a child process and will connect to it. Also, LocalDB supports attaching database files during the connection process, allowing access to the database files directly without going through the database server. Other features are:
- LocalDB runs from the same sqlservr.exe like SQL Express or other editions
- Clients use same T-SQL to connect to LocalDB
- Applications use the same providers to connect to LocalDB
- LocalDB does not create any database services
- LocalDB process are started/stopped automatically
While LocalDB is similar to SQL Server Compact in simplicity and easiness of use, there are some differences: SQL Compact runs as an in-process DLL while LocalDB runs in a separate process, Compact offers only limited RDBMS functionality while LocalDB has a much richer functionality set including Stored Procedures, Geometry and Geography data types, and others, and Compact has a very small memory footprint, its binaries amounting to 4MB while LocalDB’s binaries are 140 MB.
LocalDB is not meant to replace SQL Express, but to offer developers the possibility to develop apps with as little overhead as possible. Microsoft will continue to provide the free SQL Server Express editions for users interested in running small evaluation projects with a 10GB database size limit.