Copied from discussion thread: http://entityframework.codeplex.com/discussions/406642
For Linq2Sql and EF database first I have been able to modify the schema.table to include a database name, in Linq2Sql I managed to make it definable at runtime so that is what I'm using for multiple database joins at the moment.
I want to move over to code first but I cannot find any way to add the database to the generated SQL. I have tried several combinations with ToTable() like ToTable("table", "database.dbo") and so on. But I either get invalid table/databasename or I get extra/misplaced square brackets in the query. Tried this both in EF 5 and 6a2 but neither works for me with the hack above. I would like something like this:
public void ToTable(string tableName, string schemaName, string databaseName);
I could then pass in the second database into the mappings constructor and define it at runtime to support joins between databases on the same sql server.
Any other suggestions how to hack this with EF4-5 would be appreciated as well, needs to be runtime definable.
Perhaps once EF6 is out of alpha and beta I'll look into it myself to build a custom variant but I would prefer a out of the box solution.
Comments: This surprised me. I'll be using Views to get around it for now but wish I didn't have to.
For Linq2Sql and EF database first I have been able to modify the schema.table to include a database name, in Linq2Sql I managed to make it definable at runtime so that is what I'm using for multiple database joins at the moment.
I want to move over to code first but I cannot find any way to add the database to the generated SQL. I have tried several combinations with ToTable() like ToTable("table", "database.dbo") and so on. But I either get invalid table/databasename or I get extra/misplaced square brackets in the query. Tried this both in EF 5 and 6a2 but neither works for me with the hack above. I would like something like this:
public void ToTable(string tableName, string schemaName, string databaseName);
I could then pass in the second database into the mappings constructor and define it at runtime to support joins between databases on the same sql server.
Any other suggestions how to hack this with EF4-5 would be appreciated as well, needs to be runtime definable.
Perhaps once EF6 is out of alpha and beta I'll look into it myself to build a custom variant but I would prefer a out of the box solution.
Comments: This surprised me. I'll be using Views to get around it for now but wish I didn't have to.