我有这两个模型:
//Primary AND Foreign key 1
public int UserID {get; set;}
//Primary AND Foreign key 2
public int ProductID {get; set;}
我不知道如何将这两列同时设置为主键和外键!你能帮助我吗 ?
我有这两个模型:
//Primary AND Foreign key 1
public int UserID {get; set;}
//Primary AND Foreign key 2
public int ProductID {get; set;}
我不知道如何将这两列同时设置为主键和外键!你能帮助我吗 ?
可能你正在寻找这个
//Primary AND Foreign key 1
[Key]
public int UserID {get; set;}
[ForeignKey("UserID")]
public virtual IEnumerable<UserProfile> users;
//Primary AND Foreign key 2
public int ProductID {get; set;}
[ForeignKey("ProductID")]
public virtual IEnumerable<Product> products;
这将允许您从用户导航到产品。
如果这不是您要找的,请提供有关您需要的更多详细信息