I’m trying to justify using EntityFramework and falling at the very first hurdle. I’m using the database first approach. Here is what it looks like in SQL Server 2008 R2:

As you can see, VERY simple domain. The association is a one-to-many relationship between User.Id and Blog.UserId.
However, even with this incredibly simple domain, EF fails. When I import the tables, I get this:

As you can see, there is no association. The relationship is gone and no matter how many times I delete, regenerate, it will not appear. “Include foreign key columns in the model” is checked.
However, if I create the tables based with keys based on ints instead of GUIDs, the relationships are created.
Is this a bug, a limitation or my own stupidity?
It doesn’t inspire my confidence. How on earth will it perform in a real-life scenario, with a hundred tables and a thousand associations?
- VS 2012
- SQL Server 2008 R2
- EF 5
I’ve resolved the issue. The problem was caused by a rogue index I did not know I had on the table.
If there is a UNIQUE index on the same field as the primary key, this will cause EF to fail to generate the PK-FK relationship at all.
Simply removing the unnecessary unique index (primary enforces unique anyway), the EF designer immediately picked up the relationship.