google-code-export / dblinq2007

Automatically exported from code.google.com/p/dblinq2007
Other
0 stars 0 forks source link

DbMetal throws exception on databases with multiple schemas using SqlServer provider #206

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run DbMetal on a database with multiple schemas
2.
3.

What is the expected output? 
Map DB into classes.

What do you see instead?
Exception message: "Sequence contains more than one element."

What version of the product are you using?
r1304

On what operating system?
Windows Vista™ Business (6.0, Build 6001) Service Pack 1

Please provide any additional information below.
At DbLinq.Util.DbmlExtensions the function GetReverseAssociation cant
distinct tables from different schemas returning more than one result and
crashing at .Single() extension.

Original issue reported on code.google.com by outlanderzor on 23 Feb 2010 at 2:14

GoogleCodeExporter commented 9 years ago
Just so we're clear, we're talking about something like:

    CREATE TABLE [foo].[Names] (ID INTEGER, Name VARCHAR(20));
    CREATE TABLE [foo].[Employees] (ID INTEGER, NameID INTEGER NULL, 
        CONSTRAINT "FK_Employees_Name" FOREIGN KEY ("NameID") REFERENCES 
[foo].[Names] ("ID")
    );

    CREATE TABLE [bar].[Names] (ID INTEGER, Name VARCHAR(20));
    CREATE TABLE [bar].[Employees] (ID INTEGER, NameID INTEGER NULL, 
        CONSTRAINT "FK_Employees_Name" FOREIGN KEY ("NameID") REFERENCES 
[bar].[Names] ("ID")
    );

i.e. we have e.g. two identically named tables in different schemas which have 
a 
foreign key relationship (within or across schemas).

It looks like supporting this will require changing DbLinq.Schema.Dbml.Table to 
include the Schema name (in addition to the name) so that 
DbmlExtensions.GetReverseAssociation() doesn't find the wrong column.

Original comment by jonmpr...@gmail.com on 11 Mar 2010 at 7:01