Showing posts with label SQL CE. Show all posts
Showing posts with label SQL CE. Show all posts

Monday, July 13, 2015

SQL Server Compact ADO.NET data access performance – part 3: SELECTs

In the third instalment in this series, I will demonstrate how to implement SELECTs using the two available APIs in the SQL Server Compact ADO.NET provider. Keep in mind that the “alternative” method of SELECTing requires a corresponding index, so it will on work for simple scenarios where you are looking up on the primary key, for example – luckily, this is quite a common scenario.

I will implement the following interface method, which finds a cacheelement by it’s ID:

CacheElement FindElementByKey(Guid key);

Let’s first look at the implementation of the classic T-SQL SELECT based method:

public CacheElement FindElementByKey(Guid key)
{
    using (var command = _connection.CreateCommand())
    {
        command.Parameters.Add("@key", SqlDbType.UniqueIdentifier).Value = key;
        command.CommandText = @"SELECT [Tag], [Value], [CreatedAt], [ExpirationAt]
            FROM CacheElement
            WHERE [Key] = @key;";
        using (var reader = command.ExecuteReader())
        {
            if (reader.Read())
            {
                var result = new CacheElement();
                result.Key = key;
                result.Tag = reader.GetValue(1) == DBNull.Value ? null : reader.GetString(1);
                result.Value = (byte[])reader[1];
                result.CreatedAt = reader.GetDateTime(2);
                result.ExpirationAt = reader.GetDateTime(3);
                return result;
            }
            else
            {
                return null;
            }
        }
    }
}

This implementation uses a standard T-SQL based parameterized SELECT query. Nothing new here.

Now let us have a closer look at the implementation using TableDirect mode:

public CacheElement FindElementByKey(Guid key)
{
    using (var command = _connection.CreateCommand())
    {
        command.CommandType = CommandType.TableDirect;
        command.CommandText = "CacheElement";
        command.IndexName = "PK_CacheElement";

        using (var reader = command.ExecuteReader())
        {
            reader.Seek(DbSeekOptions.FirstEqual, key);
            if (reader.Read())
            {
                var element = new CacheElement();
                element.Key = key;
                element.Tag = reader.GetValue(1) == DBNull.Value ? null : reader.GetString(1);
                element.Value = (byte[])reader.GetValue(2);
                element.CreatedAt = reader.GetDateTime(3);
                element.ExpirationAt = reader.GetDateTime(4);
                return element;
            }
        }
        return null;
    }
}

Notice the required differences: The CommandType is set to TableDirect, the CommandText is set to the name of the table we want to query, and the IndexName property is set to the name of the index to be used. The Seek command will force a call to read to find the first matching column matching the key value. Notice that the key parameter is an params array, allowing you to use multi-column indexes.

In terms of performance, the classic SELECT appears to be 3 times slower than the TableDirect Seek, but of course your mileage may vary.

You can download the sample code from here.

Monday, March 30, 2015

SQL Server Compact & SQLite Toolbox 4.2 – Visual Guide of new features

After more than 370.000 downloads, version 4.2 of my SQL Server Compact & SQLite Toolbox extension for Visual Studio 2010 and later is now available for download and available via Tools/Extensions and Updates in Visual Studio. This blog post is a visual guide to the new features, improvements and bug fixes included in this release, many suggested by users of the tool via the CodePlex issue tracker

The main features in this release have been improved integration with SQL Server & SQLite, and a number of improvements to the SQL editor.

This version is a recommended update for anyone using this tool.

Improved SQL Server integration

I have previously used this old tip from Jon Galloway for prompting users for a connection to a SQL Server/SQL LocalDB/SQL Azure database, but this caused a number of issues when connecting to LocalDB and SQL Azure, so for this release, you will use Server Explorer to create SQL Server connections, and then I will refer to these from the Toolbox.
So to interact with SQL Server from the Toolbox (for example for scripting, generating DGML files or Exporting a full database for SQL Server to SQLite, first connect to the SQL Server via Server Explorer:

clip_image002

Then launch the Toolbox (you can do that directly from Server Explorer), and select the relevant connection from Server Explorer from the dropdown list:

clip_image003

Export SQLite to SQL Server (and LocalDB/Express)

It is now possible to migrate a SQLite database to SQL Server without running creating any intermediate scripts. Simply right click your SQLite database in the Toolbox , and select the “Migrate to SQL Server” option:

clip_image004

Select your Server Explorer SQL Server connection (as described above), and you can follow the progress of the export via the Visual Studio status bar:

clip_image005

Many thanks to @thughesit for help with improving this feature.

As SQLite is much more loosely type than SQL Server, a new option have been added that will truncate string (causing data loss) if a string has been defined with a length like nvarchar(255) and the length of the data stored in SQLite actually exceeds this. This option is disabled by default. Any truncations will be logged to %temp%\SQLiteTruncates.log
clip_image006

You can now also migrate the other way, from SQL Server to SQLite, without any intermediate scripts. Right click the root “Data Connections” node of the Toolbox and select “Export SQL Server to SQLite (beta)”

clip_image007

Choose the Server from the dropdown list:

clip_image008

Choose the tables to Export:

clip_image010

And specify the name for the new SQLite database file, and you can follow the progress of the Export via the Visual Studio status bar.

SQL editor improvements

clip_image012

The query editor has received a number of highly requested improvements:

Improved document handling:
There is now both a “Open” (1) “Save” and “Save As” (2) buttons, and each editor window is aware of its underlying document. If there is a document open, it is indicated in the window caption, and a * symbol indicates if the document has unsaved changes:

clip_image013

Keyboard shortcuts: Keyboard shortcuts have been added for "Execute" query: F5, Save: Ctrl+S
and Open: Ctrl+O – a long standing request finally implemented
Export results as CSV: A new button has been added, that will export the first results as a csv (Excel) file, saving you having to copy and paste the results to Excel.

SQLite PRAGMAs: It is now possible to execute PRAGMA commands with SQLite

Other Improvements

Migrating a SQL Compact or SQLite database to SQL Server no longer blocks the UI.
Exporting a database from SQL Server no longer blocks the UI.
No more Error Reporting dialog, I am now using Exceptionless for error reporting instead.
Improved formatting of DataAcccess.cs sqlite-net code
Improved initial directory when adding SQLite and SQL Compact connections
Improved error information when SQLite datetime parsing errors occur (SQLite allows you to put anything in a column defined as datetime, apparently!)
Improved error information when SQL Server script execution errors occur (would mainly happen when exporting from SQLite to SQL Server)
Closing the Edit Data grid now closes the connection to the database, meaning that the Toolbox will have no open connection to the database file when all Edit Grids are closed.
Update to version 1.0.96 of SQLite ADO.NET provider

Bug fixes

Migrate to SQL Server feature was broken
Merge Replication Subscription creation was broken
Edit column should not show "Primary Key" column, and not allow editing of column name
Opening the SQL Editor sometimes crashed VS
FormatException in Explorer window

Wednesday, March 25, 2015

Entity Framework 6 (and SQL Server Compact) (5)–Entity Framework 6 extensions

This is a list of some of all the nice Entity Framework 6 extensions out there that expand the functionality of the Entity Framework 6 runtime. Code generator tools and Frameworks using Entity Framework are not included here, only libraries that extend DbContext or similar.

The EF team has lists of Tools and 3rd party EF providers here: http://msdn.microsoft.com/en-us/data/ee712907

Please let me know if I have missed anything, and I will add it to the list.


Store Functions for EntityFramework CodeFirst
 

Why: This project uses the basic building blocks to build end to end experience allowing using TVFs in Linq queries and invoking stroed procedures without having to drop down to SQL. (By EF Team member)
Project: https://codefirstfunctions.codeplex.com/
NuGet: Coming soon


Interactive Pre-Generated Views for Entity Framework 6

Why: An alternative is a solution where views are created dynamically only when needed (i.e. views don't exist or are out dated) and then persisted and made available for use by other instances of the same application (be it running in parallel or the same application after a restart). This is exactly the problem Interactive Pre Generated Views project is trying to solve. (By EF Team member)
Project: https://efinteractiveviews.codeplex.com/
NuGet: https://www.nuget.org/packages/EFInteractiveViews

Second Level Cache for Entity Framework 6.1

Why: Entity Framework does not currently support caching of query results. A sample EF Caching provider is available for Entity Framework version 5 and earlier but due to changes to the provider model this sample provider does not work with Entity Framework 6 and newer. This project is filling the gap by enabling caching of query results for Entity Framework 6.1 applications.  (By EF Team member)
Project: https://efcache.codeplex.com/
NuGet: http://www.nuget.org/packages/EntityFramework.Cache


Entity Framework 6 Contrib

Why: https://ef6contrib.codeplex.com/documentation
Project: https://ef6contrib.codeplex.com/
NuGet: https://www.nuget.org/packages/EF6.Contrib/


Entity Framework Extended Library

Why: Batch Update and Delete, Future Queries, Query Result Cache, Audit Log

Nuget: http://www.nuget.org/packages/EntityFramework61.Extended (forked)
and http://www.nuget.org/packages/EntityFramework6.Extended (forked)
and https://www.nuget.org/packages/EntityFramework.Extended/
Project: https://github.com/loresoft/EntityFramework.Extended and https://github.com/AdvancedREI/EntityFramework.Extended


EntityFramework.Utilities

Why: EntityFramework.Utilities provides some batch operations for using EF that the EF team hasn't yet added for us. (CUD)
Project: https://github.com/MikaelEliasson/EntityFramework.Utilities
NuGet: https://www.nuget.org/packages/EFUtilities/


EntityFramework.BulkInsert

Why: Bulk insert extension for EntityFramework. Insert large amount of data over 20 times faster than regular insert. Supports DB first and code first.
Project: https://efbulkinsert.codeplex.com/
NuGet: https://www.nuget.org/packages/EntityFramework.BulkInsert-ef6


Trackable Entities

Why: Visual Studio 2012 and 2013 project templates and NuGet packages for client-side entity change-tracking and server-side persistence with Entity Framework extensions.
Project: http://trackableentities.github.io/
NuGet: https://www.nuget.org/packages/TrackableEntities.EF.6/

EntityFramework.MappingAPI

Why: EntityFramework mapping API gives you ability to know the database info behind the context.
Project: https://efmappingapi.codeplex.com/
NuGet: https://www.nuget.org/packages/EntityFramework.MappingAPI

EntityFramework.Filters

Why: Create and configures filters applied to queries across a DbContext
Project: https://github.com/jbogard/EntityFramework.Filters
NuGet: https://www.nuget.org/packages/EntityFramework.Filters/

EntityFramework.DynamicFilters

Why: allow you to create global and scoped filters for Entity Framework queries. The filters are automatically included in every query and can be used to support use cases such as Multi-Tenancy, Soft Deletes, Active/Inactive, etc.
Project: https://github.com/jcachat/EntityFramework.DynamicFilters
NuGet: https://www.nuget.org/packages/EntityFramework.DynamicFilters/


EntityFramework.Seeder

Why: Using EntiyFramework.Seeder, you can seed your database from CSV files.
Project: https://github.com/dpaquette/EntityFramework.Seeder/
NuGet: https://www.nuget.org/packages/EntityFramework.Seeder.EF6/

EntityFramework.Triggers

Why: Add triggers to your entities with insert, update, and delete events. There are three events for each: before, after, and upon failure.
Project: https://github.com/NickStrupat/EntityFramework.Triggers
NuGet: https://www.nuget.org/packages/EntityFramework.Triggers/

EntityFramework.IndexingExtensions

Why: Adds fluent API to model indexes
Project: https://github.com/mj1856/EntityFramework.IndexingExtensions
NuGet: https://www.nuget.org/packages/EntityFramework.IndexingExtensions/

Z.EntityFramework.Plus.EF6

Why: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit)
Project: https://github.com/zzzprojects/EntityFramework-Plus
NuGet: https://www.nuget.org/packages/Z.EntityFramework.Plus.EF6/

Monday, November 14, 2011

SQL Compact 3rd party tools

This is an attempt at a comprehensive list of SQL Server Compact Microsoft and 3rd party tools, both commercial and non-commercial. Please let me know if I have missed anything, and I will add it.

Microsoft supplied tools

Visual Studio Community 2017 free – when used with the SQL Server Compact / SQLite Toolbox: SQL CE 3.5, SQL CE 4.0

Visual Studio 2008 Professional (SQL CE 3.5)

Visual Studio 2005 Standard (SQL CE 3.1)

SQL Server 2008 R2 Management Studio Express (free, SQL CE 3.5 SP2)
Link: http://www.microsoft.com/en-us/download/details.aspx?id=30438
SQL Server 2005 Management Studio Express SP2 (free, SQL CE 3.1)
Link: http://www.microsoft.com/en-us/download/details.aspx?id=15366

New or updated entries are noted with (new) or (updated) ”Last updated” indicates when the tool was last updated by it’s author.

Non-commercial (free) tools

My GitHub Tools

Name: SQL Server Compact Toolbox (updated)
Link: https://github.com/ErikEJ/SqlCeToolbox
SQL CE Versions: 3.5, 4.0
Last updated: Current
Platforms: Win32, Win64 
Added to list: 29th June 2010
”Add-in for Visual Studio 2071/2015/2013/2012 (for 3.5 and 4.0). Standalone app (for 4.0 and 3.5)
Adds several features to help your SQL Server Compact development efforts:
- Scripting of tables, including data.
- Script of entire schema, optionally with data, both of SQL Server Compact and SQL Server 2005 or later databases, including SQL Azure.
- Import to SQL Compact 3.5 from a server database or CSV file.
- Basic, free form query execution.
- Generation of DGML files for visualizing table relationships
- Database Schema Diff Script
- Detect database file version
- Fix broken connection definitions”

Name: SqlCeScripting.dll (updated)
Link: https://github.com/ErikEJ/SqlCeToolbox  
SQL CE Versions: 3.5, 4.0
Last updated: Current
Platforms: Win32, Win64 
Added to list: 29th June 2010
”Scripting library for inclusion in your own application, enumerates SQL Compact objects and allows scripting of these.”

Name: SqlCeCmd (updated)
Link: https://github.com/ErikEJ/SqlCeCmd
SQL CE Versions: 3.5, 4.0
Last updated: 2015
Platforms: Win32, Win64
”Administer SQL Compact databases directly from the command line, without having Visual Studio or SQL Server Management Studio installed. Only requires NetFx 2.0 and SQL Compact installed. Command line options similar to sqlcmd. Runs scripts generated by ExportSqlCe.”

Name: ExportSqlCe (updated)
Link: https://github.com/ErikEJ/SqlCeToolbox/
SQL CE Versions: 3.0, 3.5, 4.0
Last updated: Current
Platforms: Win32, Win64 
”This command line utility helps you better manage your SQL Compact development efforts. If allows you to script schema and data from any SQL Compact database file to a .sql file, which can be used in any context. The utility is developed in C# with Visual Studio 2008. You can use the resulting script for documentation, programmatic scripting of SQL Compact database files, or migration of schema and data to SQL Server (Express) 2005 or later.

Name: Export2SqlCe (updated)
Link: https://github.com/ErikEJ/SqlCeToolbox
SQL Server Versions: 2005, 2008, 2012, 2014 
Last updated: Current
Platforms: Win32
Added to list: 4th March 2010
”A command line utility to script an entire SQL Server 2005 or later database with or without data to a SQL Compact T-SQL script.”

Name: SqlCeBulkCopy (updated) 
Link: https://github.com/ErikEJ/SqlCeBulkCopy
SQL CE Versions: 3.5, 4.0
Last updated: Current 
Platforms: .NET library, .NET CF library 
Added to list: 4th March 2010 
”.NET Library for loading data fast (doing bulk inserts) into a SQL Server Compact database file. Attempts to mimic the SQLClient SqlBulkCopy API. Includes support for BULK INSERTing any IEnumerable”

Query and database management tools

Name: CompactView
Link: http://sourceforge.net/p/compactview/home/Home/
SQL CE Versions: 3.1, 3.5, 4.0
Last updated: 2015
Platforms: Win32, Win64
Added to list: 14th November 2011
CompactView is a viewer for Microsoft® SQL Server® Compact Edition (SQLCE) database files (*.sdf). CompactView can open database files of versions 3.1, 3.5 and 4.0

Name: SQL Compact Query Analyzer
Link: http://sqlcequery.codeplex.com/
SQL CE Versions: 3.1, 3.5, 4.0
Last updated: 2013
Platforms: Win32, Win64
Added to list: 3rd July 2011 
Features:
- Execute SQL Queries against a SQL Server Compact Edition database
- Table Data Editor to easily edit the contents of the database
- Supports SQLCE 3.0, 3.1, 3.5 and 4.0
- Execute multiple SQL queries (delimited by a semi colon ;)
- Display query result as XML
- Shrink and Compact Databases
- Generate Schema and Data Scripts
- Display database and schema information

Name: LINQPad
Link: http://www.linqpad.net/
SQL CE Versions: 3.5, 4.0
Last updated: Current
Platforms: Win32, Win64
Added to list: 14th December 2010
Linqpad allows you to query various data sources via LINQ, including SQL Server Compact 3.5 and 4.0. See this blog post.

Name: Database .NET
Link: http://fishcodelib.com/Database.htm
SQL CE Versions: 3.1, 3.5, 4.0
Last updated: Current
Platforms: Win32, Win64
Added to list: 20th September 2010
“Database .NET is a simple and intuitive database management tool for multiple databases. Making Local and Remote Database Administration Easier, With it you can Create databases, Design tables, Edit data, Export data, Generate scripts and run SQL queries.”

Name: SQL CE Browser
Link: http://ericwillis.com/notes/2009/12/sql-ce-browser-v-110/
SQL CE Versions: 3.5
Last updated: 2010
Platforms: Win32, Win64 (?)
Added to list: 4th March 2010 
”Open regular and encrypted/passworded databases for viewing or editing. Write and work with any number of queries at once via tabs. SQL syntax highlighting and SQL syntax verification. Explore columns, keys, and indexes“

Name: Mini SQL Query
Link: http://minisqlquery.codeplex.com/ 
SQL CE Versions: 3.5
Last updated: 2014
Platforms: Win32, Win64 (?)
Added to list: 4th March 2010 
”Mini SQL Query is a minimalist SQL query tool for multiple databases (MSSQL, MSSQL CE, SQLite, OLEDB, MS Access/Excel files etc). The tool uses a generic schema engine taking advantage of the ADO.NET providers. Mini SQL Query is also easily extended with plugins.“

Name: SQL Server CE Query Tool
Link: http://cequery.codeplex.com
SQL CE Versions: 3.5, 4.0
Last updated: 2011 
Platforms: Win32, Win64 (?)
”CEQuery is written in C# with the help of Visual Studio 2008 platform. Some of the features of this tool are described below:
User is able to create CE database. If the schema is provided, the tool is able to create the tables and columns. User is able to overview an existing CE database with its table and column structure in tree format. User can design a query by dragging and dropping tables and columns from the database tree. User can manipulate [Insert/Update/Delete] records in a selected table. User is able to generate scripts from a single table or of whole databases. [Both for SQL CE or SQL Server]. User is able to open multiple SQL Server CE files simultaneously. User is able to convert a SQL Server database to a SDF file with schema and data. User is able to change password of a SQL CE DB. The tool is now capable of handling the database with no password.“

Name: SeasonStar Database Management(SSDM)
Link: http://ssdm.codeplex.com/
SQL CE Versions: 3.5?, 4.0 
Last updated: 2011
Platforms: Win32
”With support for all major database formats, top-class export functions and advanced feaures like Linq Data Context availabe, SSDM is probably your best choice for DB management. It's even free software!”

Name: SQL CE Database Editor
Link: http://sqlcedatabaseeditor.codeplex.com/
SQL CE Versions: 3.5
Last updated: 2009 
Platforms: Win32
“Small lightweight application to browse and edit Microsoft SQL CE server databases. Does not require SQL CE server to be installed and can run custom queries.”

Name: DataBoy
Link:http://databoy.codeplex.com/
SQL CE Versions: 3.0, 3.5
Last updated: 2008
Platforms: Win32
“Small footprint, portable and simple database query tool. Support SQL CE 3.1, SQL CE 3.5 and SQL Server.”

Other tools and libraries

Name: Lyare.SqlServerCe.MultiQuery (new)
Link: https://github.com/lokiworld/Lyare.SqlServerCe.MultiQuery
SQL CE Versions: 4.0
Last updated: 2014
Platforms: Win32, Win64
Added to list: 2nd March, 2014 
“An extension to the Microsoft SQL Server Compact Edition client library, which simulates the support of the multiple statements in a single command.”


Name: SQLCE SCRIPTER
Link: http://sqlmgmt.com/sql/SQLCE-Scripter
SQL CE Versions: 3.5, 4.0
Last updated: 2011
Platforms: Win32, Win64
Added to list: 14th November, 2011
“Create SQL schema scripts for tables, indexes and referential relations. Create data scripts so that CE data can be moved to SQL Server or other data store. User can select specific tables only. User can select Script Schema, Script Data or both.”

Name: SQLCE Code Generator
Link: http://sqlcecodegen.codeplex.com/
SQL CE Versions: 3.5, 4.0
Last updated: 2012 
Platforms: Win32, Win64
Added to list: 27th March, 2011
“Contains a stand alone GUI application and a Visual Studio Custom Tool for automatically generating a .NET data access layer code with Unit tests for objects in a SQL Server Compact Edition database. Also generates a Windows Phone DataContext”

Name: OpenNETCF.ORM Framework
Link: http://orm.codeplex.com/
SQL CE Versions: 3.5
Last updated: Current 
Platforms: WinCE, Win32, Win64
Added to list: 27th March, 2011
“The OpenNETCF.ORM library is a lightweight object-relational mapping framework designed for use with the .NET Compact Framework.The framework is extensible to allow any type of backing store. An initial implementation using SQL Server Compact is provided.”

Name: SQL Metal Open Source User Interface
Link: http://sqlmetalosui.codeplex.com/
SQL CE Versions: 3.5
Last updated: 2008 
Platforms: Win32
“This project provides an user interface for SqlMetal.exe tool.
SQLMetalOSUI allows users to generate code and mapping files for their SQL Server Compact Edition databases. SQL Server Compact Edition 3.5 is fully compatible with LINQ to SQL but the designer does not. This project will be focused to reach this initial purpose.”


Commercial tools


Name: MS Compact Maestro (new)
Link: http://www.sqlmaestro.com/products/mssql/compact_maestro/ 
SQL CE Versions: 3.5, 4.0
Last updated: 2013
Platforms: Win32, Win64
”MS Compact Maestro is a top-class SQL Server Compact management and development tool.”

Name: SDF Viewer 
Link: http://www.flyhoward.com/SDF_Viewer.aspx
SQL CE Versions: 3.0, 3.5, 4.0
Last updated: Current
Platforms: Win32
“The simple way to create, view, edit or export the data in your Windows Mobile or Pocket PC device's SQLCE database, from the convenience of your Desktop. Run SQL commands on your SQLCE databases, and view the results instantly.”

Name: RemoteSqlCe
Link: http://www.gui-innovations.com/html/remotesqlce.html
SQL CE Versions: 2.0, 3.0
Last updated: 2007
Platforms: Windows CE, Win32
”SqlServerCE is a great database for Pocket PC’s, but designing, maintaining and querying databases on the PPC, especially whilst developing, can be wearing. We developed this tool to help us when developing for SqlServerCE. With RemoteSQLCe you can completely manage your SqlServerCE database from the desktop. RemoteSQLCE works in the cradle, and over ethernet/bluetooth.” 

Tuesday, October 11, 2011

SQL Server Compact books

A number of SQL Compact (or a least SQL Compact related) books have appeared on the market.
I will attempt to keep this list of books up to date as new material appears.

“
Building Standalone Data-Driven Applications using SQL Server Compact 4.0 and Visual Studio 2010”
“Microsoft SQL Server Compact 4.0 (SQL Compact onwards) is a free SQL Server embedded database ideal for building standalone desktop, web, and mobile applications that need local data storage.”
 
“Microsoft SQL Server Compact 4.0 Books Online”
Microsoft SQL Server Compact 4.0 is a free, embedded database that software developers can use for building ASP.NET websites and Windows desktop applications. Download the documentation to learn about SQL Server Compact 4.0 and to build applications for it.

“La réplication du fusion avec SQL Server Compact: Implémentation and conseils”
“Free eBook in French about implementation and advise regarding Merge Replication – in many ways similar to the Rob Tiffany book.”

“.NET Compact Framework 3.5 Data Driven Applications”
“Develop data-driven mobile applications from the ground up on top of the Oracle Lite and SQL Server Compact”
 
“Microsoft SQL Server Compact 3.5 Service Pack 2 Books Online”
This download contains the Books Online for the SP2 version of SQL Server Compact 3.5.

“SQL Server MVP Deep Dives”
This book with contribution from 53 SQL Server MVPs includes 2 chapters relating to SQL Compact:
Placing SQL Server in your pocket by Christopher Fairbairn and Mobile data strategies by John Baird
http://www.manning.com/nielsen/
 
"Enterprise Data Synchronization with SQL Server 2008 and SQL Server Compact 3.5"
An update of the previous book, equally excellent and hands-on.
Available from Amazon
 
"Microsoft Mobile Development Handbook"
This book covers development using .NET Compact Framework 2.0 in broad terms, and has two chapters relating to SQL Compact:
Chapter 3 describes how to persist data using SQL Compact and how to bind SQL Compact data to UI elements and chapter 7 briefly covers using RDA and merge replication with SQL Compact.
 
"Windows Mobile Data Synchronization with SQL Server 2005 and SQL Server Compact 3.1"
I have already recommended the excellent Merge Replication book by Rob Tiffany here:
Available from amazon

"Microsoft® SQL Server 2005 Compact Edition"
This book covers the product in full, including a chapter on Native development, and several chapters on replication. The main perspective of this this book is a DBA approach, with only a single chapter covering development per se. There are also useful chapters on security and performance tuning.
 
"Hitchhiker's Guide to Microsoft SQL Server 2005 Compact Edition"
For desktop developers diving into SQL Compact, the e-book by Bill Vaughn is an excellent introduction, which covers many aspects and pitfalls of developing with SQL Compact edition in a desktop application.
 

Tuesday, November 16, 2010

Using Entity Framework with SQL Server Compact 4.0 CTP and ASP.NET – tips & tricks (part one)

As you may know by now, the major new feature of SQL Server Compact 4.0 is support for ASP.NET starter websites. In addition, the Entity Framework support has been improved with the following features:

- Support for Code First development (requires EF 4 Feature CTP 4), allowing you to create database and schema in code.

. Support for paging (can be implemented with Skip and Take in LINQ).

- Support for server generated keys (IDENTITY)

The purpose of this post is to show how to use Entity Framework 4 with SQL Server Compact 4.0 and ASP.NET without having the full support for SQL Server Compact 4.0 in VS 2010.

I will cover the following scenarios in the sample application:

1: Migrate data and schema for the solution from either SQL Server Compact 3.5 or SQL Server 2005 or later.

2: Create a Type-Per-Table Entity Data Model (EDM) based on a SQL Server Compact 4.0 database.

3: Create a layered application, where the UI has no knowledge of Entity Framework, in order to improve testability, minimize UI code and allow the Data Access layer to be replaced with another Data Access Technology (unlikely, I know Smile)

4: Provide the initial implementation of a music track list displayed in a grid, which can be sorted and paged.

5: Provide access to invoice data in Excel

6: Allow easy management of lookup tables like Genre, Artist and MediaType

7: Use various extension methods, that make your life with Entity Framework smoother.

For this sample I am using the Chinook database from CodePlex, which is delivered in script format and as a 3.5 SDF file. The Chinook database schema represents a digital media store, including tables for artists, albums, media tracks (3500 tracks), invoices and customers.

Creating the database (optionally migrating from 3.5 or Server)

Depending on your starting point, there are many ways to get to a 4.0 database.

If you have a 3.5 database, you can use SqlCeCmd40.exe to upgrade a copy of this database to 4.0:

sqlcecmd40 –d”Data Source=C:\data\Chinook40.sdf” –e upgrade

will do an in-place upgrade for you. (This requires 4.0 CTP2)

If you have a database script, either from a SQL Server database (created by Export2SqlCe.exe or from elsewhere), you can use SqlCeCmd40.exe to create an empty 4.0 database file and import the script:

sqlcecmd40 –d”Data Source=C:\data\Chinook40.sdf” –e create

sqlcecmd40 –d”Data Source=C:\data\Chinook40.sdf” –i C:\x.sql

Or you can use WebMatrix to graphically create the database. (Support for doing this in Visual Studio will come with VS 2010 SP1).

Creating the Data Access Layer

As mentioned, I will create a database first EDM. Due to the missing Server Explorer / Data Sources integration with SQL Compact 4, you will have to do this by using a workaround. I know of 2:

Either by using the command line tools as described in the blog: http://getsrirams.blogspot.com/2010/10/adonet-entity-data-model-for-sqlserver.html or

Have a 3.5 database handy with the exact same table definition (schema) as the 4.0 database. After generating the EDM based on the 3.5 database, tweak the model to work with a 4.0 database. Let’s see how this is done:

Start by creating an empty solution, named Chinook, to hold our projects:

image

Then add a C# Class library project to the solution, and name it Chinook.Data:

image

Remove Class1.cs, then go to file system, and copy the Chinook.sdf (the 3.5 version) to the solution folder (C:\projects\chinook).

image

(I have also copied the 4.0 version, so I can easily find it later). Now we can add the EDM based on the 3.5 database file:

image

Name the model ChinookModel.edmx and click Add. In the next step, select Generate From Database, and click Next.

On the “Choose you data connection” step, create a new connection to the Chinook.sdf 3.5 version database, using the SQL Server Compact 3.5 provider, and click Next:

image

Then you get this question:

image

(I suggest you reply No)

image

Select all tables, select pluralize and click Finish. Now we have our Model:

image

Now, let’s make the Model work with our SQL Server Compact 4.0 file. First, modify the connection string in app.config as follows:

image

Then modify the emdx file (right click the file, and select Open With.. XML Editor).

image

Verify your changes by opening the edmx file in the visual designer.

Creating the POCO Entities for use with Repository

Now let us create a separate class library for our POCO entities based on the model, This will allow us to reference this Model project from both the data access layer and the UI layer. In order to do this, follow the steps in this EF Team blog post, and you will end up with a solution structure like this:

image

Notice the following change,that was made to ChinookModel.tt in order to have the entities in a separate project:

string inputFile = @"..\Chinook.Data\ChinookModel.edmx";

Also, a reference to the Chinook.Model project was added to Chinook.Data:

image

And the Custom Tool Namespace for the Chinook.Model.Context.tt file was set to Chinook.Model:

image

Creating the Repository

Now, add a Chinook.Repository project to the solution, to create the data access methods used by the UI. This project should reference the Chinook.Model and the Chinook.Data projects. As always, remove the Class1.cs file. Now, we want to create a method that allows the UI to get a page of Track data for display in a GridView. This is an initial implementation (notice the parameters, which are passed by default when using and ObjectDataSource from the UI):

public List<Track> GetAll(string sortBy, int maximumRows, int startRowIndex)
{
using (var context = new ChinookEntities())
{
return context.Tracks.Include("Albums").Include("Artists").Include("Genres").ToList();

}
}


There are some things missing/not ideal with this:

- The Include statements are based on text strings.


- Sorting and paging is not implemented



In order to make the Include statement strongly typed, I have located an extension method from http://blogs.microsoft.co.il/blogs/shimmy/archive/2010/08/06/say-goodbye-to-the-hard-coded-objectquery-t-include-calls.aspx (Implemented in the ObjectQueryExtensions.cs file in the Chinook.Data project)



public List<Track> GetAll(string sortBy, int maximumRows, int startRowIndex)
{
using (var context = new ChinookEntities())
{
return context.Tracks.Include(t => t.Album.Artist).Include(t => t.Genre).ToList();
}
}


That’s much better, and avoids nasty runtime errors.



The sortBy parameter from the ObjectDataSource is just a text string (field name), optionally followed by “DESC”. So to do sorting, we could write a long case statement to set the sortexpression, or use another extension method, which accepts a sort expression. I found one here: http://landman-code.blogspot.com/2008/11/linq-to-entities-string-based-dynamic.html




public List<Track> GetAll(string sortBy, int maximumRows, int startRowIndex)
{
using (var context = new ChinookEntities())
{
if (string.IsNullOrWhiteSpace(sortBy))
{
sortBy = "Name";
}
return context.Tracks.Include(t => t.Album.Artist).Include(t => t.Genre).OrderUsingSortExpression(sortBy).Skip(startRowIndex).Take(maximumRows).ToList();
}
}


In addition to the GetAll method, in order to support paging, the repository must also implement a GetCount method: 



public int GetCount()
{
using (var context = new ChinookEntities())
{
return context.Tracks.Count();
}
}


Creating the UI Layer



Now, add a ASP.NET Web Application project. Call it Chinook.UI. Add a “WebForm using Master”, and call it TrackList.aspx. Add references to Chinook.Model and Chinook.Repository.



Add this content to TrackList.aspx:



image



Notice the highlighted sections in the markup.



Add the connection string entry from the Data project to web.config.



Set the UI project as Start Project and the TrackList.aspx as start page.



Press F5 and see it run!



To display the Album title rather than the albumId, add a AlbumName readonly property to a new Track.Custom.cs POCO partial class, and display the Album.Name when requested:



//For display only
public string AlbumName
{
get
{
if (this.Album != null)
{
return this.Album.Title;
}
else
{
return string.Empty;
}
}
}


Then change the asp:boundfield from AlbumId to AlbumName in the TrackList.aspx file (you can do the same for other foreign key fields)



<asp:BoundField DataField="AlbumName" HeaderText="Album" 
SortExpression="" />


Download the project so far from here.



In part 2, we will continue with the following additional features:



- Adding a Dynamic Data Project to quickly manage the lookup tables



- Creating an OData layer, allowing access from PowerPivot in Excel



- Deployment advice



(Thanks to Morten Hedekær Olsson for technical review)

Wednesday, August 25, 2010

SQL Server Compact version detector

With three current SQL Server Compact versions (file formats) available 
3.0/3.1 on Windows Mobile 6.x devices,
3.5 with Visual Studio 2008 and 2010,
and 4.0 currently available as a CTP (Community Technical Preview),
it can sometimes be hard to tell what the file version of a SQL Compact file in your possession is.

To help you, I have created a small utility that you can place on your desktop and drop any SQL Server Compact file on.

You can download a .zip file with the utility here. And the source code for the utility is available here.

Place the SQL Compact Detector.exe on your desktop, and drop a SQL Server Compact file on it!

image

image

Wednesday, July 7, 2010

SQL Server Compact 4.0 CTP1 released

The SQL Server Compact team has just released of CTP of version 4.0 of SQL Server Compact Edition.

Ambrish Mishra has a detailed blog about the new features. Here is a short summary:

ASP.NET support

The main feature of version 4.0 is support for using SQL Compact as a file based database engine with ASP.NET websites.

The work done to enable ASP.NET includes:

Higher Reliability – can handle load of starter websites

Setup Enhancements – easier private deployment and a single x64 installer.

Support for ASP.NET – removal of the ASP.NET blocker

Virtual Memory Reduction – allows up to 256 concurrent connections (max) without virtual memory errors.

Medium Trust – enables web hosting with .NET 4.0

It is a part of the recently announced WebMatrix tool for starter websites as a starter database engine, which also includes a tool to design the database used on the website:

image

T-SQL changes

Support for paging queries:

SELECT * FROM Customers ORDER BY [Customer ID] OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY;

ADO.NET Provider enhancements

Seamless Integration with ADO.NET Entity Framework 4.0 (.NET FX 4) – server generated keys and code first support coming soon.

System.Data.SqlServerCe.SqlCeConnection.GetSchema() – allows you to get schema information for use in scripting tools etc.

System.Data.SqlServerCe.SqlCeConnectionStringBuilder() –allows you to build a strongly typed connection string.

Migration

The WebMatrix tools includes a tool to migrate a SQL Compact database to SQL Server 2006/2088/Azure. The tool does not generate a script, but simply creates a new database on the server selected.

image

For migration from SQL Server to SQL Compact, (and script based migration from SQL Compact to SQL Server), you can continue to use my ExportSqlCe tools. I have described the procedure to migrate from SQL Server to SQL Server Compact here. In addition, I have just released SQL Server Compact 4.0 versions of ExportSqlCe and SqlCeCmd.

Visual Studio

Later, a Visual Studio update will enable you to use SQL Server Compact from the Visual Studio Data/Server Explorer, including from Visual Web Developer Express. I assume a similar update for SQL Server Management Studio (SSMS) is not in the cards.

Sunday, July 4, 2010

Content overview

My CodePlex SQL Server Compact tools

SQL Server Compact & SQLite Toolbox 4.4 & 4.5 – Visual Guide of new features
SQL Server Compact & SQLite Toolbox 4.3 – Visual Guide of new features
SQL Server Compact & SQLite Toolbox 4.2 – Visual Guide of new features

“SQL Server Compact & SQLite Toolbox” related news


SQLite & SQL Server Compact Toolbox 4.1 – Visual Guide of new features


SQLite Toolbox 4.0 – Visual Guide of Features


SQL Server Compact Toolbox 3.7.3 – Visual Guide of new features


SQL Server Compact Toolbox 3.7.2–Visual Guide of new features


SQL Server Compact Toolbox 3.7.1–Visual Guide of new features


SQL Server Compact Toolbox 3.7–Visual Guide of new features


Document your SQL Server database with free tools: SQL Server Compact Toolbox and DB>Doc
SQL Server Compact Toolbox 3.6–Visual Guide of new features
SQL Server Compact Toolbox 3.4–Visual Guide of new features
SQL Server Compact Toolbox 3.3–Visual Guide of new features
Some SQL Server Compact Toolbox usage graphs
SQL Server Compact Toolbox 3.2–Visual Guide of new features
SQL Server Compact Merge Replication Library alpha released
SQL Server Compact Toolbox 3.1.1 with support for Windows Phone 8 and VS 2012 released
SQL Server Compact Toolbox 3.1–Visual Guide of new features
SQL Server Compact Toolbox 3.0–Visual Guide of new features
SQL Server Compact Toolbox hits 100.000 downloads–new release planned
Migrating databases between SQL Server and SQL Server Compact
SQL Server Compact Toolbox 2.6–Visual Guide of new features
SQL Server Compact Toolbox 2.5–Visual Guide of new features
SQL Server Compact Toolbox available for Visual Studio 11

SQL Server Compact Toolbox 2.4–Visual Guide of new features

SqlCeBulkCopy, a library for fast SQL Server Compact INSERTS released
SQL Server Compact Toolbox 2.3–Visual Guide of new features
SQL Server Compact Toolbox 2.2–Visual Guide of new features
SQL Server Compact ASP.NET Membership, Role and Profile Provider version 2.1 now available
SQL Server Compact Toolbox standalone - including all managed DLLs in a single .exe
New release of Scripting Library and command line utilities–with Schema Diff and DGML from command line
SQL Server Compact Toolbox 2.1–Visual Guide of new features
SQL Server Compact Toolbox 2.0–Visual Guide of new features
New release of ExportSqlCe SSMS add-in and command line utilities–Script to SQL Azure

SQL Server Compact Toolbox add-in now supports version 4.0 databases

SQL Server Compact 4.0 ASP.NET Membership provider

SQL Server Compact version detector

How to Migrate/Downsize a SQL Server database to SQL Server Compact 4.0 (and 3.5)

SQL Server Compact 3.5 Toolbox updated

“SQL Compact Toolbox” – manage merge replication subscriptions

 “SQL Compact Toolbox” Visual Studio 2010 add-in be...

Version 3 of ExportSqlCE now available

SQL Server Compact Bulk Insert Library

Script SQL Server Compact tables in Management Stu...

SqlCeCmd tutorial part two – Creating database obj...

SqlCeCmd tutorial part one – Managing database fil...

SqlCeCmd tutorial part three – query options

Using ExportSQLCE from Visual Studio

Entity Framework Core

Getting started with the SQL Server Compact and other providers for Entity Framework 7 beta 6

Getting and building the Entity Framework 7 alpha bits – step by step

Entity Framework ”reboot” – EF7 – Get a sneak peek via TechEd US live stream

Entity Framework 6

A breaking change in Entity Framework 6.1.2 when using EDMX and SQL Server 2008/2005

Entity Framework 6 and SQL Server Compact 4.0 (10) – “Proper” private desktop deployment
Entity Framework 6 and SQL Server Compact (9) –SqlCeFunctions and DbFunctions
Entity Framework 6 & SQL Server Compact (8) –Logging SQL statements
Entity Framework 6 & SQL Server Compact (7) –New features and fixes in version 6.1
Entity Framework 6 & SQL Server Compact (6)–Entity Framework Reverse POCO Code First Generator
Entity Framework 6 (& SQL Server Compact) (5)–Entity Framework 6 extensions
Entity Framework 6 & SQL Server Compact 4.0 (4) - Restoring full EF Tools support in Visual Studio 2013

Entity Framework 6 & SQL Server Compact (3)–Getting started with the SQL Server Compact 3.5 provider (and Merge Replication)

Entity Framework 6 & SQL Server Compact 4 (2)–Easy Private Desktop Deployment

Entity Framework 6 & SQL Server Compact 4 (1)–Workflows and tooling

INSERTing many rows with Entity Framework 6 beta 1 and SQL Server Compact

Fix for Entity Framework poor INSERT performance with SQL Server Compact and server generated keys

Fixing the Entity Framework designer “Generate Database from Model” T4 template

Entity Framework 4.x

Viewing SQL statements created by Entity Framework with SQL Server Compact

Saving images to SQL Server Compact with Entity Framework 4.1 Code First

Using SQL Server Compact 4.0 with WPF DataGrid, Entity Framework 4 and Private deployment (part 1)

Using SQL Server Compact 4.0 with Desktop Private Deployment and a Setup project (MSI) (part 2)

Entity Framework with SQL Server Compact 4.0 and ASP.NET – Dynamic Data, OData, deployment (part two)

Using Entity Framework with SQL Server Compact 4.0 CTP and ASP.NET – tips & tricks (part one)

Solutions to: “Server-generated keys and server-ge...

SQL Compact and Entity Framework woes

Deployment

The trouble with Any CPU–Prefer 32 bit–BadImageFormatException

SQL Server Compact 4 desktop app with simple Private Deployment and LINQ to SQL

Private deployment of SQL Server Compact 3.5 SP2

SQL Server Compact Private Deployment tweaks

SQL Server Compact “Private Deployment” on desktop–an overview

How to detect if the x64 SQL Compact 3.5 SP2 deskt...

Requirements for SQL Compact installations on x64 ...

Running SQL Compact from CD-ROM (read only media) ...

x64 and SQL Compact

Sort order issue when moving sdf files between pla...

SQL Compact internals and T-SQL

SQL Server Compact ADO.NET data access performance – part 1: Overview

SQL Server Compact ADO.NET data access performance – part 2: INSERTs

SQL Server Compact ADO.NET data access performance – part 3: SELECTs

SQL Server Compact 4.0 SP1 hotfix available

SQL Server Compact breaks when upgrading from Windows 8 to Windows 8.1

FAQ: Why is opening my SQL Server Compact database slow?

Scripting image column data for INSERT statements

Useful new topics in SQL Server Compact 4.0 Books Online

Comparison of SQL Server Compact 4, 3.5 SP2 and SQL Server Express 2008 R2

SQL Server Compact 3.5 SP2 downloadable update list

SQL Compact Table Copy/Export samples published

What’s new in SQL Server Compact 3.5 SP2 beta

Dealing with very large SQL Compact database files...

SQL Server 2005 Compact Edition downloadable hotfixes...

SQL Compact 3.5 SP1 downloadable hotfix list

Scripting SQL datetime fields and avoiding localiz...

SQL Compact 3.5 knowledge base articles

Working with Case Sensitive SQL Compact databases

Testing an sdf file for version info

TOP clause now supported

Hidden gem: Rename table

Code snippet of the week

SQL Server Compact Code Snippet of the Week #1 : locate the ROWGUIDCOL column in a table

SQL Server Compact Code Snippet of the Week #2 : locate the IDENTITY column in a table

SQL Server Compact Code Snippet of the Week #3 : locate the rowversion column in a table

SQL Server Compact Code Snippet of the Week #4 : select rows 50 to 60 from a table

SQL Server Compact Code Snippet of the Week #5 : rename a table

SQL Server Compact Code Snippet of the Week #6 : list all user tables in a database

SQL Server Compact Code Snippet of the Week #7 : get the full path to a database file

SQL Server Compact Code Snippet of the Week #8 : script a database to SQLite

SQL Server Compact Code Snippet of the Week #9 : migrate a SQL Compact database to SQL Server

SQL Server Compact Code Snippet of the Week #10 : generate a CREATE TABLE script

SQL Server Compact Code Snippet of the Week #11 : detect if SQL Server Compact is available

SQL Server Compact Code Snippet of the Week #12 : get the SQL Server Compact runtime version

SQL Server Compact Code Snippet of the Week #13 : reseed (reset) an IDENTITY column

SQL Server Compact Code Snippet of the Week #14 : script all data in a table

SQL Server Compact Code Snippet of the Week #15 : flush data to disk immediately 

SQL Server Compact Code Snippet of the Week #16 : detect Entity Framework database type

SQL Server Compact Code Snippet of the Week #17 : using wildcards with a parameterized query

SQL Server Compact Code Snippet of the Week #18 : handling SqlCeExceptions

SQL Server Compact Code Snippet #19 : migrate a SQL Server database to SQL Compact

SQL Server Compact Code Snippet #20 : change database password

Using SQL Server Compact

Visual Studio

Visual Studio 11 beta - Tooling for SQL Server Compact

Analyzing SQL Server Compact queries using Visual Studio 2010 Premium/Ultimate

SQL Server Compact Toolbox standalone - including all managed DLLs in a single .exe

Visual Studio 2010 Service Pack 1 with support for SQL Server Compact 4.0 released

Migrate a SQL Server Compact database to SQL Server using Web Deploy (MSdeploy)

Using SQL Server Compact 4.0 with WPF DataGrid, Entity Framework 4 and Private deployment (part 1)

Using SQL Server Compact 4.0 with Desktop Private Deployment and a Setup project (MSI) (part 2)

Visual Studio Tools for SQL Server Compact 4 now available

Using Entity Framework with SQL Server Compact 4.0 CTP and ASP.NET – tips & tricks (part one)

SQL Compact 4.0 now available as a .zip file

HOW TO: Detect SQL Server Compact version information

HOW TO: Upgrade a version 3.x database file to SQL Server Compact 4.0

How to check the Visual Studio 2010 edition from code

FAQ: Why does my changes not get saved, SQL CE doe...

Diagram database table relationships using DGML, S...

Using the ADO.NET Data Connection dialog in your o...

How to save and retrieve Images using LINQ to SQL ...

Using SQL Compact with Log4net

Two great tutorials

Crystal Reports with SQL Compact

Accessing SQL Compact from SQL Server "Linked Serv...

x64 and SQL Compact

SQL Compact 3.5 - Manage relationships

Windows Phone

Useful Windows Phone advice from Nick Randolph

Windows Phone / SQL Server Compact resources

Populating a Windows Phone “Mango” SQL Server Compact database on desktop

SQL Server Compact Toolbox 2.2–Visual Guide of new features

Windows Phone Local Database tip: Viewing the SQL generated by LINQ to SQL

Windows Phone Local Database tip: Batch INSERT performance

Windows Phone Local Database tip: Exploring INSERT performance–5 power tweaks

Generating a LINQ to SQL DataContext for VS Express for Windows Phone

Windows Phone Local Database tip: Initializing the database

SQL Server Compact Toolbox 2.6.1–Visual Guide of new features

Windows Phone Local Database tip: Exploring multiple UPDATEs and rowversion impact

Windows Phone Local Database tip: Working with encrypted database files

Windows Phone Local Database tip: Exploring DELETE performance and a “Bug Alert”

Generate a Windows Phone 8 Local Database DataContext from an existing database

Windows Mobile

SQL Compact 3.5 OLEDB C++ sample now available

SQL Compact versions on Windows Mobile

New SQL Server Compact training video

ADO.NET Sync Services for Devices sample

SQL Compact version on Windows Mobile 6.5

Mobile Application Pocket Guide v1.1

Intro to Mobile Sync

Windows Mobile platform support

Mobile sample using SQL Compact

SQL Compact Device Deployment

ASP.NET

SQL Server Compact 4.0 under ASP.NET Hosting– common issues

Using Entity Framework with SQL Server Compact 4.0 CTP and ASP.NET – tips & tricks (part one)

Entity Framework with SQL Server Compact 4.0 and ASP.NET – Dynamic Data, OData, deployment (part two)

Getting started with SQL Server Compact 4.0 (no WebMatrix)

ASP Classic

Access SQL Server Compact 4 with ASP Classic and VbScript

VBA (Office)

Tips and tricks for using SQL Server Compact with VB/VBA/VBScript/ASP

Inserting images from VBA

Import SQL Compact data to Excel

OData (WCF Data Services)

WCF Data Services with Windows Phone - bandwidth requirements measured

Entity Framework with SQL Server Compact 4.0 and ASP.NET – Dynamic Data, OData, deployment (part two)

Walkthrough: Expose SQL Compact data to the world ...

Silverlight

Access a local SQL Compact database from Silverlig...

WPF

Using SQL Server Compact 4.0 with WPF DataGrid, Entity Framework 4 and Private deployment (part 1)

Using SQL Server Compact 4.0 with Desktop Private Deployment and a Setup project (MSI) (part 2)

Binding SQL Compact data to WPF in less than 100 l...

LINQ to SQL

Using LINQ to SQL with SQL Server Compact 4.0 (yes, you can!)

How to save and retrieve Images using LINQ to SQL ...

SQL Compact and LINQ to SQL performance advise

LINQ to SQL

 

SQL Server Management Studio

How to clear the list of recently opened SQL Serve...

SQL Server 2008 Management Studio Express

Accessing SQL Compact from SQL Server "Linked Serv...

SQL Compact 3.5 - Manage relationships

PowerShell

Using PowerShell to manage SQL Server Compact database files

F#

HOW TO: Connect to SQL Server Compact from F#

CodeSmith

Getting started with a CodeSmith nettiers data acc...

Merge Replication

Shop Talk” with Eric Sink, Zumero for SQL Server founderShop Talk” with Eric Sink, Zumero for SQL Server founder
An alternative to Merge Replication with SQL Server and SQL Server Compact – Zumero for SQL Server
Merge Replication with SQL Server Compact 3.5 SP2 and SQL Server 2014 and 2012

SQL Server Compact 3.5 SP2 now supports Merge Replication with SQL Server 2012

Snapshot Synchronization with SQL Server Compact 4.0

Walkthrough: Configuring the Merge Replication Age...

Recent Synchronization and Replication advice from...

IIS 7.5 (Windows Server 2008 R2) and SQL Compact i...

Is RDA (Remote Data Access) still relevant

SQL Compact Merge Replication “bible” updated

Merge replication performance tips

Merge Replication and ISA Server

Intro to Mobile Sync

SQL Compact 3.5 client agent logging

Versions...versions

Sync Framework

Sync Framework news roundup

Recent Synchronization and Replication advice from...

2 new Sync Services hotfixes for SQL Compact

Sync SQL Compact with SQL Azure and Oracle

Microsoft Sync Framework 2.0 released to web!

ADO.NET Sync Services for Devices sample

New features in Sync Framework

Recent Sync Framework articles

SQLite

“Database First” with SQLite in a Universal App using the SQLite Toolbox and sqlite-net

Getting started with SQLite in Windows Store / WinRT apps

Exporting SQL Server Compact to SQLite

Other news stories

Using Exceptionless.com for error logging and feature usage tracking with a Visual Studio add-inUsing Exceptionless.com for error logging and feature usage tracking with a Visual Studio add-in

SQL Server Data Tools for Visual Studio – versions, downloads and compatibility

SQL Server - using newsequentialid() as a function, similar to newid()

Primeworks, supplier of tools for SQL Server Compact, is closing, making all products free, open source

Integrating Red Gate SmartAssembly in the SQL Server Compact Toolbox

SQL Server Compact 4.0 SP1 Released To Web

The state and (near) future of SQL Server Compact

SQL Server Compact 4.0 SP1 CTP1 available

SQL Server Compact will be available for developers in upcoming Windows Phone “Mango” update

SQL Server Compact 4.0 released!

SQL Server Compact 4.0 CTP2 released

SQL Server Compact 4.0 news roundup

SQL Compact 4.0 CTP1 released

SQL Server Compact 3.5 SP2 released!

What’s new in SQL Server Compact 3.5 SP2 beta

No SQL Compact on Windows Phone 7?

New KB article about how to remove SQL Compact 3.5...

Interview with SQL Server Compact Program Manager ...

Dynamics Mobile – SQL Compact used in MS Dynamics ...

News from blog land

3rd party tools

SQL Compact 3rd party tools

Books

New book: .NET Compact Framework 3.5 Data Driven Applications

SQL Server Compact Edition books

SQL Compact Merge Replication “bible” updated

Mobile Application Pocket Guide v1.1

Architecture Journal 14