Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tables from two different databases in a DBML?

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

like image 949
MetaGuru Avatar asked Sep 04 '09 16:09

MetaGuru


People also ask

Can we join tables from two different databases?

SQL Server allows you to join tables from different databases as long as those databases are on the same server. The join syntax is the same; the only difference is that you must fully qualify table names.

Can we join two tables different databases in mysql?

Yes, assuming the account has appropriate permissions you can use: SELECT <...> FROM A. table1 t1 JOIN B.

How do I join two tables in another database in Oracle?

Mark, Create DB link in between selected databases and then grant privileges to schema where you are trying to join the tables.


1 Answers

It is entirely possible to reference multiple databases within the same DBML, PROVIDED those databases reside on the same SQL Server.

In Visual Studio, right-click on the DBML, click "Open with..." , and select XML (Text) Editor with Encoding.

You will see your first table that you dragged in looks like this:

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

For your tables from other databases you wish to add, enter them like this:

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

This will work assuming the same login works for both databases, and your LINQ expressions can now query across both databases!

like image 68
zax Avatar answered Nov 15 '22 08:11

zax