EF6: Foreign keys are not recognized on model generation for Sql Server DB

c#, entity-framework, sql-server

Solution

Entity framework does not support unique constraints which unfortunately leaves the PK as the only candidate key.

Problem

I'm getting started with Entity Framework and I'm trying to generate a model based on an already existing database. Most of the tables have foreign key references to other tables on unique identifiers that do not happen to be the primary key of the table. It seems like the model generation is completely ignoring the FK references. The error list shows the following: Error 6035: The relationship 'My foreign key constraint' has columns that are not part of the key of the table on the primary side of the relationship. The relationship was excluded. Here's a look at the model and error list Anybody have any ideas? Is it just that EF doesn't like FK constraints on fields that aren't the primary key? Thanks in advance.

Original source