Hi Zak, I had this problem yesterday as well, I believe its due to the multiple foreign key references to the same lookup table, basically the code will iterate your FK's and see that you have one to your tool table and try to create a 'tool' member for it, the problem is that it does this for each FK pointing to the tables, so you end up with 2 of them.
Unfortunately I have not yet found a solution to this problem in DBLinq, this is exactly the situation where a visual editor would come in handy as the references could be manually edited to be more meaningful names and remove the duplicates. Sorry I cant offer a solution, I wonder if anyone else has run into this in the past and found a solution? Cheers On Wed, Feb 11, 2009 at 1:01 AM, Zak <[email protected]> wrote: > > I am getting build errors related to foreign keys with code generated > from svn rev 969. > > Basically I end up with multiple definitions with the same name for > EntityRef for the "profile" table, and the same with EntitySet for the > "tool" table. > > When I generate my code I am: > -getting the .dbml > -grabbing a few specific tables > -generating .cs from the edited .dbml > > This has worked well, until this table definition (postgresql edited > for brevity): > > CREATE TABLE ihs.profile > ( > id serial NOT NULL, > ... > cope_tool_id integer NOT NULL, > ... > panel_tool_id integer NOT NULL, > ... > stick_tool_id integer NOT NULL, > CONSTRAINT profile_pkey PRIMARY KEY (id), > CONSTRAINT cope_tool_fkey FOREIGN KEY (cope_tool_id) > REFERENCES ihs.tool (id) MATCH SIMPLE > ON UPDATE NO ACTION ON DELETE NO ACTION, > CONSTRAINT panel_tool_fkey FOREIGN KEY (panel_tool_id) > REFERENCES ihs.tool (id) MATCH SIMPLE > ON UPDATE NO ACTION ON DELETE NO ACTION, > CONSTRAINT stick_tool_fkey FOREIGN KEY (stick_tool_id) > REFERENCES ihs.tool (id) MATCH SIMPLE > ON UPDATE NO ACTION ON DELETE NO ACTION > ) > WITH (OIDS=FALSE); > > Note the multiple constraints to the same column tool.id > > The relevant dbml (edited for brevity): > > <Table Name="ihs.profile" Member="Profile"> > <Type Name="Profile"> > <Association Name="cope_tool_fkey" Member="Tool" Storage="_tool" > Type="Tool" ThisKey="CopeToolID" OtherKey="ID" IsForeignKey="true" > Cardinality="Many" /> > <Association Name="panel_tool_fkey" Member="Tool" > Storage="_tool" Type="Tool" ThisKey="PanelToolID" OtherKey="ID" > IsForeignKey="true" Cardinality="Many" /> > <Association Name="stick_tool_fkey" Member="Tool" > Storage="_tool" Type="Tool" ThisKey="StickToolID" OtherKey="ID" > IsForeignKey="true" Cardinality="Many" /> > ... > <Column Name="cope_tool_id" Member="CopeToolID" > Storage="_copeToolID" Type="System.Int32" DbType="integer(32,0)" > IsDbGenerated="false" CanBeNull="false" /> > ... > <Column Name="panel_tool_id" Member="PanelToolID" > Storage="_panelToolID" Type="System.Int32" DbType="integer(32,0)" > IsDbGenerated="false" CanBeNull="false" /> > ... > <Column Name="stick_tool_id" Member="StickToolID" > Storage="_stickToolID" Type="System.Int32" DbType="integer(32,0)" > IsDbGenerated="false" CanBeNull="false" /> > </Type> > </Table> > > and > > <Table Name="ihs.tool" Member="Tool"> > <Type Name="Tool"> > <Association Name="tool_item_id_fkey" Member="Item" > Storage="_item" Type="Item" ThisKey="ItemID" OtherKey="ItemID" > IsForeignKey="true" Cardinality="Many" /> > <Association Name="cope_tool_fkey" Member="Profile" > Storage="_profile" Type="Profile" ThisKey="ID" OtherKey="CopeToolID" > Cardinality="One" DeleteRule="NO ACTION" /> > <Association Name="panel_tool_fkey" Member="Profile" > Storage="_profile" Type="Profile" ThisKey="ID" OtherKey="PanelToolID" > Cardinality="One" DeleteRule="NO ACTION" /> > <Association Name="stick_tool_fkey" Member="Profile" > Storage="_profile" Type="Profile" ThisKey="ID" OtherKey="StickToolID" > Cardinality="One" DeleteRule="NO ACTION" /> > ... > <Column Name="id" Member="ID" Storage="_id" Type="System.Int32" > DbType="integer(32,0)" IsPrimaryKey="true" IsDbGenerated="true" > CanBeNull="false" Expression="nextval('ihs.tool_id_seq')" /> > ... > </Type> > </Table> > > > Next (arrg my eyes!) the generated .cs (edited for brevity): > > [Table(Name = "ihs.profile")] > > public partial class Profile : INotifyPropertyChanged > > {... > private EntityRef<Tool> _tool; > > [Association(Storage = "_tool", ThisKey = "CopeToolID", Name = > "cope_tool_fkey", IsForeignKey = true)] > > [DebuggerNonUserCode] > > public Tool Tool_CopeToolID > > {... > > private EntityRef<Tool> _tool; > > [Association(Storage = "_tool", ThisKey = "PanelToolID", Name = > "panel_tool_fkey", IsForeignKey = true)] > > [DebuggerNonUserCode] > > public Tool Tool_PanelToolID > > {... > > private EntityRef<Tool> _tool; > > [Association(Storage = "_tool", ThisKey = "StickToolID", Name = > "stick_tool_fkey", IsForeignKey = true)] > > [DebuggerNonUserCode] > > public Tool Tool_StickToolID > > {... > > and > > [Table(Name = "ihs.tool")] > > public partial class Tool : INotifyPropertyChanged > > {... > private EntitySet<Profile> _profile; > > [Association(Storage = "_profile", OtherKey = "CopeToolID", Name = > "cope_tool_fkey")] > > [DebuggerNonUserCode] > > public EntitySet<Profile> Profile_CopeToolID > > {... > > private EntitySet<Profile> _profile; > > [Association(Storage = "_profile", OtherKey = "PanelToolID", Name = > "panel_tool_fkey")] > > [DebuggerNonUserCode] > > public EntitySet<Profile> Profile_PanelToolID > > {... > > private EntitySet<Profile> _profile; > > [Association(Storage = "_profile", OtherKey = "StickToolID", Name = > "stick_tool_fkey")] > > [DebuggerNonUserCode] > > public EntitySet<Profile> Profile_StickToolID > > {... > > > Hopefully, I have included enough information, but not so much as to > bug your eyes out. Obviously, if all the source is needed I have no > problem sending it. > > While I might be able to make a guess at how to edit the generated cs, > I'd rather get to the bottom of the problem. > > If anyone can help point me in the right direction, that would be > great. Also if I should opening an "issue" is prefered please let me > know. > > Thanks, Zak > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
