Sunday, January 30, 2011

Useful Things to Know, #428

Contrary to a lot of what you’ll find said online, Linq to SQL seems to work fairly happily with tables from different SQL Server databases (but the same server) in the same model.  You just have to put the full name (including the database) into the Name property of the entities representing tables in the “foreign” database.  You can even build associations between tables from different databases:  Linq to SQL will take your word for it that those relationships exist.

A caveat: I have only tested this on VS 2008 (what I happen to be working with right now) and I haven’t attempted anything fancy with updates or inserts (since what I’m working on doesn’t require them).  But, since I found people saying emphatically that cross-database modeling couldn’t be done in Linq to SQL, I wanted to report that it can. 

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home