Tuesday, July 12, 2011

Sql CE & LINQ with SQL Metal

To start programming with LINQ against SQL CE 3.5, as if a table in Sql CE is a class, you can make use of SQL Metal.

This post is a good guide to start off with.


Use the below command to generate the cs and dbml file.

Generate DBML file

C:\Program Files\Microsoft Visual Studio 9.0\VC>sqlmetal /dbml:J:\Sid\WinApps\Auto-motive\Auto-motive\AutoDB.dbml J:\Sid\WinApps\Auto-motive\Auto-motive\AutoDB.sdf
Microsoft (R) Database Mapping Generator 2008 version 1.00.30729
for Microsoft (R) .NET Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.

Generate CS file

C:\Program Files\Microsoft Visual Studio 9.0\VC>sqlmetal /Code:J:\Sid\WinApp
s\Auto-motive\Auto-motive\AutoDB.cs J:\Sid\WinApps\Auto-motive\Auto-motive\AutoDB.sdf
Microsoft (R) Database Mapping Generator 2008 version 1.00.30729
for Microsoft (R) .NET Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.