Linq to Sql – How-to Separate the entities and the DataContext.

added by sedanwer
3/14/2010 2:25:22 PM


Yesterday we started to use Linq to Sql in a project at work. We didn’t select NHibernate but kind of wanted a clean model anyway, where the entities are separated and not bundled in the same class as the context. We also wanted clean entities: No partial methods; No (by us) unused INotify-interfaces. We also wanted the DataContext to live in an own assembly, so it’s not included in the assembly that holds the entities. Ok, so whith al these demands you probably think that NHibernate would be a better choice, well it wasn’t that hard to accomplish a solution that fullfilled our needs, and that’s what this post is about.