请问如下 projectUser表是双主键(projectId,userId).其中projectId既是主键又是外键。怎么样设置与project表ID的关联呢。如果我在projectUser中加ID作为主键是可以的,但是设计数据表时这样是不允许的。 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.
添加回答
举报
0/150
提交
取消