简体   繁体   English

使用Microsoft Sync Framework自动创建客户端架构

[英]Automatically Creating Client Schema with Microsoft Sync Framework

I need to make a local copy of a database in a .NET app so that it can function offline. 我需要在.NET应用程序中创建数据库的本地副本,以便它可以脱机运行。 My server database is SQL Server 2005, and it's copying to SQL Server 2008 Express. 我的服务器数据库是SQL Server 2005,并且正在复制到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. 我一直在研究Microsoft Sync Framework,看来我必须为数据库中的每个表制作一个SyncTable,坦率地说,这似乎需要太多的工作和维护。 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? 我是否在Sync Framework中缺少某些东西,或者还有其他东西可以完成这种事情?

I gave up on Sync Framework; 我放弃了Sync Framework; using SQL Server Management Objects to accomplish this instead. 使用SQL Server管理对象来完成此任务。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM