开发者

How to generate DataContext for SQL Server Compact database?

开发者 https://www.devze.com 2023-03-08 17:10 出处:网络
I just started to use LINQ-to-SQL, so my problem may be trivial. We have a central database running on SQL Server 2005. There are distributed desktop .NET 4 applications which save measurement data i

I just started to use LINQ-to-SQL, so my problem may be trivial.

We have a central database running on SQL Server 2005. There are distributed desktop .NET 4 applications which save measurement data into a local SQL Server Compact database. These local database (SDF) files are regularly transported to the server, where they are imported into the central database using SqlBulkCopy.

The distributed desktop applications use LINQ-to-SQL to handle data and to create their local SDF database. The ORM is currently done by a manually written DataContext subclass, compiled as a separate library, which contains a nested class for every table of the central database. I wrote the DataContext subclass by hand simply because I wanted to avoid code generators before I more-or-less understand how LINQ-to-SQL works.

The central database is simple at the moment, but it will structurally expand soon, by adding new tables and adding new versions of existing tables. The problem is, it would be nice to automate the generation of the DataContext subclass. In an ideal situation, this could be done as part of the daily build process. This way after the database team changes the database, the application developer team would get the new version of the ORM library. (Old code would not break, since every old table would stay in the database. Old versions of the tables will be deleted only when none of the distributed application versions use them.)

So my question is, what is the best way to generate a DataContext subclass for an existing database? I would prefer a command l开发者_如何学JAVAine tool or an API. Thank you for your help in advance!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号