Edit: the issue is solved in the newer versions of EF. At least that's what I assume since I recently created a new project and followed the same steps and everything went fine! Thanks for your comments and helps. I leave the original question, untouched, below.
I'm using the Entity Framework for the first time. I have a strange problem: I have this small database on SQL Server. Here is the diagram from the management studio:
As you can see, the foreign keys are all defined. To generate the edmx model, I selected "New Item -> ADO.NET Entity Data Model -> Generate from database". This is what I get:
All associations but two are missing! This is odd since the good old L2S could recognize them with no problem:
Can anybody help me fix it?
You use the DbContext Scaffold command to generate the model. The command has two required arguments - a connection string and a provider. The connection string will depend on your environment and database provider.
Now, to model your entities, there are three approaches in EF Core. These include: Code First, Model First and Database First. When following the Code First approach you would typically create the entity classes initially.
The answer to our problem in this case is that we had Unique Non-Clustered Index on some of the primary keys - this caused a problem for the EF model (but not in Linq2SQL). Changing the indexes on these keys to Unique Clustered Index fixed the problem!
Are you checking the option of "Include foreign key columns in the model"?
(source: msdn.com)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With