Trying to access two different databases with the same connection string with LINQ
I'm trying to access two different databases with the same connection string with LINQ. However I'm getting an error which suggests my LINQ statement is using the default database as named in the connection string.
I'd rather not add another connection in the web.config and want to use the same connec开发者_开发百科tion string but to a different db on the same db server.
I realise I need to do something with mappingSource when I initialise the source, but my searches so far have drawn a blank.
If you only need to query data out of a second database on the same db server you could create views on the first database that point to the second.
I'd caution against doing the view creation if the databases are on separate servers as you can get pretty bad latency issues. For that matter I'd caution against joining tables from multiple servers at all...
精彩评论