title: LinqToSQL - mapping out the DataContext with lots of tables?
body: <p>I've been working on a project where I have been using <code>LinqToSQL</code> that involved a lot of tables. All of these where mapped in one <code>.dbml</code> file (i.e. only one <code>DataContext</code>). I did this on the pretense that (currently) you cant join across multiple data contexts. For example...</p>
  
  <pre><code>DB1DataContext db1 = new DB1DataContext();
  DB2DataContext db2 = new DB2DataContext();
  
  var query =
      from x in db1.SomeTable
      join y in db2.AnotherTable on x.Id equals y.Id
      select new
      {
          x.Column,
          y.Column
      };
  </code></pre>
  
  <p>Someone argued that this isn't so, and I should break the <code>.dbml</code> file down into seperate smaller (i.e <em>more</em> managable) data contexts. I've now just set up an example, run a similar query to the one above and got the following error...</p>
  
  <blockquote>
    <p>base {System.SystemException} = {"The
    query contains references to items
    defined on a different data context."}</p>
  </blockquote>
  
  <p>I am curious, am I missing something? What are the common practices where there are a lot of tables that require mapping? How can you break down a .dbml file?</p>