I have a database with multiple tables which have the same name but are from different schemas. For example:
[DatabaseName].[Schema1].[MyTable]
[DatabaseName].[Schema2].[MyTable]
When Linq2Sql generates code for this database, it appears to just be picking up the table from the first schema and completely ignoring the second schema:
[Table(Name="[Schema1].MyTable")]
public partial class MyTable { }
This effectively makes it impossible to query the table on the second schema using Linq2Sql. Is there a workaround for this?
My first idea is to manually edit the generated code so that I have:
[Table(Name="[Schema1].MyTable")]
public partial class Schema1MyTable { }
[Table(Name="[Schema2].MyTable")]
public partial class Schema2MyTable { }
but having to maintain this code every time the database changes would be a huge pain. Any other ideas?