請問如下 projectUser表是雙主鍵(projectId,userId).其中projectId既是主鍵又是外鍵。怎么樣設(shè)置與project表ID的關(guān)聯(lián)呢。如果我在projectUser中加ID作為主鍵是可以的,但是設(shè)計數(shù)據(jù)表時這樣是不允許的。 public class Project { public Guid ID { get; set; } public string ProjectName { get; set; } } public class ProjectUser { public Guid ProjectID { get; set; } public string UserID { get; set; } public virtual Project Project { get; set; }}以上異常信息如下:One or more validation errors were detected during model generation:
System.Data.Edm.EdmEntityType: : EntityType 'ProjectUser' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet ?ProjectUser? is based on type ?ProjectUser? that has no keys defined.
- 2 回答
- 0 關(guān)注
- 428 瀏覽
添加回答
舉報
0/150
提交
取消
