I built a simple ADO.Net MVC project in Visual Studio 2015 by following the tutorial found here. My project works, but I wanted to add more tables to the database and create several foreign key relationships between them and the existing tables. I added an ADO.Net Entity Data Model (Project Properties > Add > New Item > Data > ADO.Net Entity Data Model > EF Designer from Data Model) with all tables selected. I'm using the (localdb)\MSSQLLocalDB that's installed with Visual Studio.
My intention was to create my new tables and FK-relationships in the .edmx diagram, then "Forward Engineer" the modified model back into the database. However, only 5 of the 6 tables created by the ASP.NET MVC template were added to the table. The AspNetUserRoles table was not added.
Can anyone explain why the table was not added and what I should have done to create the new tables and key relationships? I prefer to work in a graphical environment as I am not a DB/SQL expert.
For anyone looking up this:
If you have a table formed of two Foreign Keys combined to form the Tables Primary Key and no other properties in the table the Entity Framework will not add this table to the Model although it exists in the background.
You do not need the intermediate Join table. The EF will add the Navigation property.
So in this case you would use something like: (User Object).Roles.add(new userrole object); save context changes to update;