The table is missing from the "EF Designer from database" .edmx diagram

I built a simple ADO.Net MVC project in Visual Studio 2015, following the tutorial here . My project works, but I wanted to add more tables to the database and create some foreign keys between them and existing tables. I added the ADO.Net Entity Data Model (Project Properties> Add> New Item> Data> Entity ADO.Net Data Model> EF Designer from the Data Model) with all the tables selected. I am using (localdb) \ MSSQLLocalDB installed with Visual Studio.

My intention was to create my new tables and FK relationships in the .edmx diagram, and then the Forward Engineer of the modified model to return to the database. However, only 5 of the 6 tables created by the ASP.NET MVC template were added to the table. An AspNetUserRoles table has not been added.

Can someone explain why the table was not added and what I had to do to create new tables and key relationships? I prefer to work in a graphical environment, as I am not an expert on DB / SQL.

+6
source share
3 answers

For those who are looking for this:

If you have a table consisting of two foreign keys combined to form the main key of the tables 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 a staging table Join. EF will add the Navigation property.

So, in this case, you will use something like: (Custom object) .Roles.add (new custom object); save context changes for updating;

+7
source

Ef requires a primary key from the table. If the primary flaw in the table than EF will ignore this table. Find details here

+1
source

You did not select AspNetUserRoles when you initially generated the model. Use the checkboxes to select the desired tables.

To add it, right-click on the designer, select "Update Model from Database ..." in the context menu. Under the first "Add" tab. expand "Tables", then expand "dbo" and select "AspNetUserRoles" using the checkbox and other tables that may be required. Click Finish to update your model and EDMX

0
source

All Articles