我只需要获取实体的复合主键。
我的实体:
public class UserRole
{
public int ID_User {get;set;}
public int ID_Role {get;set;}
}
我的实体映射:
public class UserRoleMap: EntityTypeConfiguration<UserRole>
{
// Primary Key
this.HasKey(t => new { t。ID_User, t.ID_Role });
// Properties
this.Property(t => t.ID_User)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
this.Property(t => t.ID_Role)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
// Table & Column Mappings
this.ToTable("User_Role");
this.Property(t => t.ID_User).HasColumnName("ID_User");
this.Property(t => t.ID_Role).HasColumnName("ID_Role");
}
我的目标是获得“ID_User”和“ID_Role”。我真的不知道该怎么做...
谢谢。问候, 莱昂娜