Table missing from 'EF Designer from database' .edmx diagram

asp.net-mvc c# entity-framework sql-server

Question

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.

1
10
11/11/2015 10:06:55 PM

Accepted Answer

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;

14
11/12/2015 2:53:20 PM

Popular Answer

Ef requires primary key from table. If primary missing in table than EF will ignore that table .Find details here



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow