1 out of 2 rated this helpful - Rate this topic

SQL Server Compact 3.5 and LINQ to SQL

SQL Server Compact 3.5 is the default database installed with Visual Studio 2008. 

This topic outlines the key differences in usage, configuration, feature sets, and scope of LINQ to SQL support.

By default, SQL Server Compact 3.5 is installed for all Visual Studio editions, and is therefore available on the development computer for use with LINQ to SQL. But deployment of an application that uses SQL Server Compact 3.5 and LINQ to SQL differs from that for a SQL Server application. SQL Server Compact 3.5 is not a part of the .NET Framework, and therefore must be packaged with the application or downloaded separately from the Microsoft site.

Note the following characteristics:

  • SQL Server Compact 3.5 is packaged as a DLL that can be used against database files (.sdf extension) directly.

  • SQL Server Compact 3.5 runs in the same process as the client application. The efficiency of communication with SQL Server Compact 3.5 can therefore be significantly higher than communicating with SQL Server. On the other hand, SQL Server Compact 3.5 does require interoperability between managed and unmanaged code with its attendant costs.

  • The size of the SQL Server Compact 3.5 DLL is small. This feature reduces the overall application size.

  • The LINQ to SQL runtime and the SQLMetal command-line tool support SQL Server Compact 3.5.

  • The Object Relational Designer does not support SQL Server Compact 3.5.

The SQL Server Compact 3.5 feature set is much simpler than the feature set of SQL Server in the following ways that can affect LINQ to SQL applications :

  • SQL Server Compact 3.5 does not support stored procedures or views.

  • SQL Server Compact 3.5 supports only a subset of data types and SQL functions.

  • SQL Server Compact 3.5 supports only a subset of SQL constructs.

  • SQL Server Compact 3.5 provides only a minimal optimizer. It is possible that some queries might time out.

  • SQL Server Compact 3.5 does not support partial trust.

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
To use SQLMetal with a SQLCompact Edition Database
  1. Open a Visual Studio Tools command prompt
  2. Navigate to the directory with your SDF file
  3. Run SQLMetal.exe on your SDF file. For example if your file was budget.sdf (for help on options use SQLMetal /?)C:\Budget>SQLMetal /dbml:budgetdata.dbml budget.sdf
  4. Go back to Visual Studio and includ the budgetdata.dbml file in the solution
Need more info on the SQLmetal command line tool and how to use it
It would be helpful here to include more information about why you have to use the SQLmetal command line tool and how to do this. For a new user of Linq and Compact SQL this is not obvious.