Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Foreign key problem
Message
De
06/02/2010 03:36:22
 
 
À
06/02/2010 03:26:23
Information générale
Forum:
ASP.NET
Catégorie:
LINQ
Versions des environnements
Environment:
ASP.NET
Divers
Thread ID:
01447781
Message ID:
01447892
Vues:
22
>>>>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.
>>>>
>>>> I thought that appeared automatically if the key was defined in the database.
>>>>
>>>>Any ideas what I might have missed.
>>>>
>>>>
>>>>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).....
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform