数据库表有 2 列 PK -(ID, ClientID)其中ClientID是 FK,ID列设置为identity。该实体的流畅 NH 映射:
CompositeId(x => x.Id)
.KeyProperty(x => x.Id, "ID")
.KeyProperty(x => x.ClientId, "ClientID");
在尝试插入新行时 NH 告诉Invalid index 10 for this SqlParameterCollection with Count=10.据我了解,它也尝试插入ID值,但由于它被配置为身份,因此无需插入ID。
是否可以像使用非复合 id.KeyProperty(x => x.Id, "ID")一样将映射配置为身份?