On Thu, 2009-10-15 at 06:05 -0700, Magickal wrote:
> Now I get the followng error:
>
> C:\temp\DbLinq-0.18\DbLinq-14102009\build.dbg>DbMetal.exe "/conn:Data
> Source=arealdb;User ID=dbuser; Password=dbuser;" -Provider:Oracle -
> database=areal -code:TestDatabase.cs
> DbLinq Database mapping generator 2008 version 0.19
> for Microsoft (R) .NET Framework version 3.5
> Distributed under the MIT licence (http://linq.to/db/license)
>
> >>> Reading schema from Oracle database
> <<< writing C# classes in file 'ArealDatabase.cs'
> DbMetal failed:System.InvalidOperationException: Sequence contains
> more than one element at System.Linq.Enumerable.Single[TSource]
> (IEnumerable`1 source)
...
> Any suggestions for what I can do abou this?
Apparently DbLinq doesn't like your database schema.
The problematic code is:
// we use Single() because we NEED the opposite association
// (and it must be here
var reverseTable =
(from t in schema.Table where t.Type.Name == association.Type
select t)
.Single();
// same thing for association
var reverseAssociation =
(from a in reverseTable.Type.Associations
where a.Name == association.Name && a != association
select a)
.Single();
return reverseAssociation;
Assuming the line numbers are correct, 'reverseTable' is found, but
'reverseAssociation' refers to more than one association.
What does that *mean*? Foreign key relationships. It's generating
"Attachement handlers" -- methods like:
private void Products_Attach(Product entity)
{
entity.Category = this;
}
In order to do so, it needs to know which field/property on the target
("entity") needs to refer to 'this' (in the above code, the Category
property), so that foreign key relationships are maintained.
DbLinq currently assumes that there is only one such column. Apparently
in your database schema there is more than one, so DbLinq fails.
The fix? A nice small test case and a patch to DbLinq. :-)
A workaround? I don't know. Perhaps you have some tool which can
generate a .dbml file from your database, and then you can provide
the .dbml file to DbMetal to generate the actual types. Otherwise, it
requires an actual fix.
- Jon
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DbLinq" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/dblinq?hl=en
-~----------~----~----~----~------~----~------~--~---