I have a database with several tables that have the same name, but from different schemas. For example:
[DatabaseName].[Schema1].[MyTable]
[DatabaseName].[Schema2].[MyTable]
When Linq2Sql generates code for this database, it simply compiles the table from the first schema and completely ignores the second schema:
[Table(Name="[Schema1].MyTable")]
public partial class MyTable { }
This actually makes it impossible to query the table in 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 to maintain this code every time a database change is a huge pain. Any other ideas?
source
share