Managing LINQ to SQL .dbml model complexity

This question is addressed to a degree in this question on LINQ to SQL .dbml best practices, but I am not sure how to add to a question.

One of our applications uses LINQ to SQL and we have currently have one .dbml file for the entire database which is becoming difficult to manage. We are looking at refactoring it a bit into separate files that are more module/functionality specific, but one problem is that many of the high level classes would have to be duplicated in several .dbml files as the associations can't be used across .dbml files (as far as I know), with the additional partial class code as well.

Has anyone grappled with this problem and what recommendations would you make?


Take advantage of the namespace settings. You can get to it in properties from clicking in the white space of the ORM.

This allows me to have a Users table and a User class for one set of business rules and a second (but the same data store) Users table and a User class for another set of business rules.

Or, break up the library, which should also have the affect of changing the namespacing depending on your company's naming conventions. I've never worked on an enterprise app where I needed access to every single table.


通过一定的大小,使用xml而不是dbml设计器可能会更容易。


I have written a tool too! Mine is for scripting changes to dbml files using c# so you can rerun them and not lose changes. See my blog http://www.adverseconditionals.com 4 more details

链接地址: http://www.djcxy.com/p/41772.html

上一篇: 我如何在python中进行monkeypatching?

下一篇: 管理LINQ to SQL .dbml模型的复杂性