MVC4 FLUENTAPI配置数据库映射的一张表报错
表RoleUser,两个字段RoleId,UserId,在配置映射关系时,需要配置一个组合主键,按下面写法,却是错误,请问这是什么原因??
public class RoleUserMap : EntityTypeConfiguration<RoleUser>
{
public RoleUserMap()
{
HasKey(b => new { b.RoleId, b.UserId });
}
}
报错提示:
The properties expression 'b => new <>f__AnonymousType6`2(RoleId = b.RoleId, UserId = b.UserId)' is not valid. The expression should represent a property: C#: 't => t.MyProperty' VB.Net: 'Function(t) t.MyProperty'. When specifying multiple properties use an anonymous type: C#: 't => new { t.MyProperty1, t.MyProperty2 }' VB.Net: 'Function(t) New With { t.MyProperty1, t.MyProperty2 }'.
PM>