With all this the-last-week-before-the-release fuss I’ve completely missed the RC0 release of the MS SQL Server 2012 “Denali”.
Among many other features (probably Microsoft itself is better to explain about them), there is new SQL Express version called LocalDB or, as they call it, SQL Express for developers.
So let’s try to connect to a LocalDB-hosted database from a Data Abstract for .NET application.
Setting up the server
Installing LocalDB is quite straightforward – just download the installer and run it.
But there is a small problem – SQL Server Management Studio is not included in the standalone LocalDB installer, probably to minimize the installer size.
So I had to download the entire Denali RC0 installation DVD and install SSMS from there.
Creating a new database
We’ll create a PCTrade database because we already have the database creation script for it and there are server and client applications that use the full MS SQL Server-based PCTrade database.
The database creation process is very similar to the ‘real’ MS SQL Server:
- Connect to the SQL Server using (localdb)\v11.0 as server name
It seems that Management Studio in RC0 still has a bug. If you just enter a database name in the ‘New Database’ dialog and press enter the process will fail:
- Create the database structure and populate the tables with data
The database creation script is shipped with the Sample Server (on Windows7 it can be found in the folder c:\Users\Public\Documents\RemObjects Samples\Data Abstract for .NET\Server\Scripts ).
There are no errors when it is executed against the LocalDB instance.
The only change that is needed is to remove the first SQL lines where the database itself is created, because we have already created the PCTrade database in the previous step.
Changes in the Data Abstract for .NET application
In the following chapter, the Sample Server application shipped with Data Abstract for .NET will be modified.
Now we need to adjust the Sample Server connection definitions file.
Open the c:\Users\Public\Documents\RemObjects Samples\Data Abstract for .NET\Server\DASampleServer.Wpf.2010.sln solution.
Double-click the daSchema file in the Solution Explorer.
Once the Schema Modeler is be started, you’ll need to change the PCTrade.MSSQL connection definition. Set its ConnectionString to
This means that so far Schema Modeler cannot access LocalDB data in any way (sure we will fix this by the time Denali is out ;).
But this doesn’t mean that the Sample Server application will also fail. All you need to do is set both Sample Server’s projects to use .NET Framework 4.0 instead of 3.5.
Now compile and run the server.
Et voilà! The server is fully accessible and provides data served by the LocalDB instance.
As you see it is very easy to add support of this cutting-edge database server to a Data Abstract-based application without writing a single line of code.