c# - Creating many to many junction table in Entity Framework -


I am trying to add many to many relatives among my two organizations. I need a junction table with an additional area, I know that EF can not do it automatically and I need to make a unit for my junction table.

I have the following models

  Public category suppliers {Public Entry ID (Receive; Set;} Public Virtual Icoding & lt; Supplier User & gt; Userpresses { Public string user {public string id {get; set;} public virtual iconing & lt; provider user & quot;; & quot; Gt; userpress {receive; set;}}  

For me a junction for a user There is a need to have permission to store stored in it, so I have created the following unit

  public class supplier user {public string UserId {get; set;} public int supplier ID {received; set;} Public Supplier User Promotion Permission {Receive; Set;} Public Virtual Supplier Supplier {Received; Set;} Public Virtual User User {Received; Set;}}  

In my OnModelCreating I have also added the following (this is probably where I am getting wrong)

  Modlbilder Anti Lieutenant; Supplier User & gt; (). Hack (x = & gt; new {x.UserId, x.SupplierId});  

It works to an extent, I can successfully add a user / supplier / permission in this table.

But I rarely have users / suppliers on this table (possibly due to PK?).

How can I change my code so that I can add the same user or supplier several times in this table?

This is how the structure of a table looks like this:

Current junction table structure

Thanks.

If I understand you correctly, you want to add several identical pairs of UPIID and Suppliers, Supplier users, right?

Add a Supplier User ID field to your Suppliers user unit and make it the primary key.

  public class supplier user {Get ready; } Public String UserId {get; Set; } Public Int supplier ID {receipt; Set; } Public Supplier User Permission Permission {Receive; Set; } Public Virtual Supplier Supplier {Receiving; Set; } Public Virtual User User {Received; Set; }}  

Configuration on MODEL CREATIVE ()


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -