Tag Archives: SQL Server

Generate MERGE scripts for all tables in a database

If you have been using the Database Projects (.sqlproj) in Visual Studio 2010 to maintain your database schema in version control, you probably need a good way to store static data for your application in version control as well. There are pre and post deployment scripts to handle that, but one of the cool things about SQL Server 2008 is that it allows for MERGE statements to perform the correct operation on the database side based on the state of the data in your target DB.

This let’s you specify what the static (also called seed, lookup table, and default) data needs to look like in a declarative way!

It’s very powerful, but often times by the time you get around to storing your database in version control, you already have tons of tables with tons of static data in there… and it would be a pain to hand-code all of the SQL MERGE statements.
Continue reading


Target SQL Server and SQL CE with the same Entity Framework objects while using Sync Framework

When developing a sometimes-disconnected application in .NET, you have the ability to create a “local data cache” (Sql CE file) and then synchronize this local database with a server database periodically (when connected) to keep the data relevant.

Of course to actually interact with the data from your .NET application, you will want to create a data model with Entity Framework. There are a few tricks that can make the whole process much simpler.
Continue reading