Dapper.Contrib
Dapper.Contrib copied to clipboard
writing non-primary key id field
given the below simplified class:
[Table ("TableName")]
public class ClassName
{
[ExplicitKey]
public Guid PKId { get; set; }
public string Id { get; set; }
}
dapper contrib's Insert seems to be skipping the Id writing completely.
and for whatever it's worth, the naming convention around this particular table is out of my control.
i just had another thought in that i tried the following and it worked:
[Table ("TableName")]
public class ClassName
{
[Key]
[ExplicitKey]
public Guid PKId { get; set; }
public string Id { get; set; }
}
however, the PKID field is indeed set by the application, not the database so having [ExplicitKey] is more appropriate
any thoughts on this behavior?