Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Foreign key problem
Message
From
06/02/2010 05:31:35
 
 
General information
Forum:
ASP.NET
Category:
LINQ
Environment versions
Environment:
ASP.NET
Miscellaneous
Thread ID:
01447781
Message ID:
01447893
Views:
27
>>>>>HI
>>>>>
>>>>>I've created a database in SQL2008. Two tables with a foreign key relationship.
>>>>>
>>>>>Then in Visual Studio2008 I'm trying to create a LINQ to SQL Data Model.
>>>>>
>>>>>I drag the tables onto the design surface but no Foreign key is appearing.
>>>>>
>>>>>Thanks
>>>>>
>>>>>Nick
>>>>
>>>>Hmm I am not a EF person as of yet so take this with a grain of salt. I had heard the model hid the foreign key when there was a relationship set up as it takes care of that for you. Might want to do a search on that to see if I heard correctly.
>>>>Tim
>>>
>>>Tim - I *think* you're thinking of the way EF will hide an intermediate linking table (when it contains only the keys). But I don't think it applies to L2Sql - and even it it did it wouldn't do so in this case where only two tables are involved.
>>>
>>>But Nick - can you clarify what you mean by "no foreign key is appearing".
>>>Do you mean there's no association showing up in the diagram?
>>>Can you, as Naomi suggested, post the code to create the DB?
>>
>>As an update If I add an entity model it does show the foreign key.
>>
>>Maybe the worked example in the book nerdinners is juts inaccurate and the dbml doesn't show foreign keys.l
>
>Just this second created your DB in SQL2005 and used it to create a DBML.
>The association shows up as expected ( one to many, Dinner.DinnerId -> RSVP.DinnerId)
>Do you still get the problem is you delete the Linq to Sql files that were created and try again from scratch?
>You can also try adding it yourself in the designer (right click / Add/ Association).....

I've run through the creation cycle a couple of times and it doesn't change.

I did just create the association in the designer and that worked.

Just seems to be a problem when building it from the database.

It raises an interesting question. (hope its not a stupid one)

How do you keep you L2S or EF model up to date. ie in step with your database.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform