0

I have a database model in entity framework. The edmx has some tables and now I am trying to add two new ones (they are junction tables). I have seen that someone added these 2 tables in the past but for some reason these tables were not being shown in the diagram. They are not listed in the list of Entity Types (under Diagram node), but I do see it in the Entity Store.

I have done below things:

  1. Edit edmx file and delete all the entries regarding to these 2 tables. Then from edmx designer I have added these 2 junction tables through 'update model from database..." option. These 2 junction tables are shown there and they are available to be added. Tables continue without being shown in diagram.
  2. Select and delete all the tables in the edmx diagram and then add all them again to the edmx. Again, tables continue without being shown in diagram.

These 2 tables have their primary key and also foreign keys pointing to other tables already shown in the edmx diagram. Also these 2 tables are junction tables as a result of a many to many relationship between 2 tables.

Also I have restarted visual studio, clean all the solution and rebuild again without success.

Any idea what can I do to add these 2 tables?

UPDATE #1: Also classes are not being created in the disk.

SQL Server definition for one of the tables is as below (the another table is similar):

CREATE TABLE [dbo].[DeptPerson](
    [deptId] [int] NOT NULL,
    [personId] [varchar](20) NOT NULL,
 CONSTRAINT [PK_DeptPerson] PRIMARY KEY CLUSTERED 
(
    [deptId] ASC,
    [personId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY]
) ON [PRIMARY]

ALTER TABLE [dbo].[DeptPerson]  WITH CHECK ADD  CONSTRAINT [FK_DeptPerson_Department] FOREIGN KEY([deptId])
REFERENCES [dbo].[Department] ([deptId])
GO

ALTER TABLE [dbo].[DeptPerson] CHECK CONSTRAINT [FK_DeptPerson_Department]
GO

ALTER TABLE [dbo].[DeptPerson]  WITH CHECK ADD  CONSTRAINT [FK_DeptPerson_Person] FOREIGN KEY([personId])
REFERENCES [dbo].[Person] ([personId])
ON DELETE CASCADE
GO

ALTER TABLE [dbo].[DeptPerson]  CHECK CONSTRAINT [FK_DeptPerson_Person]
GO

UPDATE #2: AS Gert Arnold explained, junction tables (intermediate tables) are being hidden by design in many to many relationship (my case). Also it is confirmed in this post. I didn't know that junction tables were being hidden by design...

Willy
  • 9,848
  • 22
  • 141
  • 284
  • Try to regenerate the EDMX completely. Also, not-supported data types may prevent tables from being incorporated in the EDMX. – Gert Arnold May 21 '20 at 19:25
  • @GertArnold How do you regenerate the EDXM completely? I have update my post. I have indicated the SQL Server table definition for one of the tables (The another table is similar). – Willy May 21 '20 at 19:46
  • 1
    This is by design. Many to many relationships have hidden junction tables in the EDMX designer. – Gert Arnold May 21 '20 at 19:48
  • @GertArnold Yes, these 2 tables are junction tables as a result of a many to many relationship between two tables so then is it normal that these junction tables are not being shown in edmx diagram? Out of curiosity, why these junction tables are being hidden by default/design? Is there any way to make these junction tables visibles in the edmx or not? – Willy May 21 '20 at 19:54
  • 1
    It's easier in querying. You don't have to navigate across the bridge table yourself to go from Person to Department vv. – Gert Arnold May 21 '20 at 20:08
  • @GertArnold Thanks! I didn't know that junction tables (intermetidate tables) as a result of many to many relationships were being hidden by design. I thought something was wrong preventing them from displaying on the diagram... – Willy May 21 '20 at 20:23

0 Answers0