views:

163

answers:

1

I need to make a local copy of a database in a .NET app so that it can function offline. My server database is SQL Server 2005, and it's copying to SQL Server 2008 Express.

It doesn't have to be anything fancy - just start from scratch (or delete the existing db), copy all tables/constraints/foreign keys, and copy data from some of the tables. I don't mind keeping a "schema version" in my database so that the app knows when its existing schema is outdated.

I've been looking into the Microsoft Sync Framework, and it appears that I have to make a SyncTable for each table in my database, and frankly, that seems like too much work and maintenance. This is the code that I'm finding in examples:

SyncTable orderDetailSyncTable = new SyncTable("OrderDetail");
orderDetailSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable;
orderDetailSyncTable.SyncDirection = SyncDirection.Snapshot;
orderDetailSyncTable.SyncGroup = orderSyncGroup;
this.Configuration.SyncTables.Add(orderDetailSyncTable);

I suppose I could list all the tables in my database and enumerate over them, but it just seems like there should be a better way. Am I missing something in the Sync Framework, or is there something else that would accomplish this sort of thing?

A: 

I gave up on Sync Framework; using SQL Server Management Objects to accomplish this instead.

http://msdn.microsoft.com/en-us/library/ms162169.aspx

Tim Ridgely