Tables from two different databases in DBML?

After dragging two tables from one database, I switch to another and drag the table. Now I get a message if I want to replace the connection string with a new one. I need tables from multiple databases in one DBML. Is it possible?

+5
source share
4 answers

I do not believe that what you are looking for is possible, since a DataContext will then not have an easy way to resolve the results from two separate databases.

If you want to create domain objects from two separate databases, then the best option would be to have two separate DBML, and then use a bridge (GOF) or some other related design pattern to create your domain objects.

+3

DBML, SQL Server.

Visual Studio DBML, " ..." XML (Text) .

, , , :

< Name= "dbo.MyTable1fromMyDatabase1" Member = "MyTable1fromMyDatabase1" >

, , :

< Name= "MyDatabase2.dbo.MyTable1fromMyDatabase2" Member = "MyTable1fromMyDatabase2" >

, , LINQ !

+5

Another option is to create a server link in the database that points to another, and make aliases for the remote tables from the "local" database. I believe that you can refer to them as if they were in the same database.

0
source

We can also create a view that queries a table in another database. We can select, insert and update this view, which will also affect the table in another database.

0
source

All Articles