SQL Foreign Keys do not generate Entity Framework Associations
Whenever I add my tables from a database into my entity model editor, none of the foreign keys "auto-generate" the respective associations. I've included a few examples of table creation scripts in case they provide some insight into what I'm doing wrong (and to prove I'm actually using foreign/primary keys).
Here's what I've tried so far:
Checking/Unchecking Include foreign key columns in the model (in the Entity Data Model Wizard)
Checking/Unchecking Pluralize or singularize generated object names
Adding only two tables (the ones I posted below)
Getting rid of identity columns
I loaded the AdventureWorks database sample and imported it to the entity model, and those associations were generated. I compared my database settings/schema to it, and no differences jumped out at me.
I've used LINQ to SQL before with no issues. Those associations generate fine. But using LINQ to SQL is going to be a last resort for me. I'm honestly thinking of recreating the structure in the entity model and then using it to create the database, but that will take forever.
are the foriegn keys physically mapped in db or they are virtually mapped. Open the table (which contains foreign keys) in SQLServer management studio and go to the foriegn key column and check relationships...
DG_Dan
ASKER
How do I check this? In SSMS, I right-clicked the table, and selected Design. Then I right-clicked the column and selected Relationships... I highlighted the foreign key name, but I don't see anything that indicates physical vs virtual mappings.
BuggyCoder
did you see the key icon in front of your foreign key in table. this can be checked by expanding columns in a table under ssms