aspnetboilerplate/aspnetboilerplate · error · ArgumentException
' ' is a key field and cannot be ignored.
Error message
'{0}' is a key field and cannot be ignored. What it means
Guard in MemberMap.Ignore(): the member {0} currently has a KeyType other than NotAKey and SlapperIdentifierKey, meaning it is an active mapped key. ABP Dapper forbids ignoring a key field because doing so would silently drop it from generated SQL, so the fluent Ignore() call is aborted with this ArgumentException.
Solutions
- Clear or change the key assignment on this member before calling Ignore(), so its KeyType is NotAKey.
- Ignore a different, non-key property instead of the key field {0}.
- If the member should no longer be a key, restructure the ClassMap so the key is mapped on another property.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/Abp.Dapper/Dapper-Extensions/Mapper/MemberMap.cs:183 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of aspnetboilerplate/aspnetboilerplate@2323c13a15 (2026-09-08).
Data as JSON: /api/errors/a7af6b84d28d680d.
Report an issue: GitHub.
Appendix: source
Thrown at src/Abp.Dapper/Dapper-Extensions/Mapper/MemberMap.cs:183
}
if (!string.IsNullOrEmpty(SequenceName) && keyType != KeyType.SequenceIdentity)
{
throw new ArgumentException(string.Format("'{0}' cannot be made a key field. ", Name));
}
KeyType = keyType;
return this;
}
/// <summary>
/// Fluently sets the ignore status of the property.
/// </summary>
public MemberMap Ignore()
{
if (KeyType != KeyType.NotAKey && KeyType != KeyType.SlapperIdentifierKey)
{
throw new ArgumentException(string.Format("'{0}' is a key field and cannot be ignored.", Name));
}
Ignored = true;
return this;
}
/// <summary>
/// Fluently sets the read-only status of the property.
/// </summary>
public MemberMap ReadOnly()
{
if (KeyType != KeyType.NotAKey && KeyType != KeyType.SlapperIdentifierKey)
{
throw new ArgumentException(string.Format("'{0}' is a key field and cannot be marked readonly.", Name));
}
IsReadOnly = true;
return this;View on GitHub (pinned to 2323c13a15)