Skip to the content.

Usage of [Column] attribute and [DbValue] attributes are conflicting - Dapper will choose either one or another’s name override.

This conflict can lead to unexpected behavior, so we recommend to use only one of them.

Bad:

class MyType
{
    [DbValue(Name = "MyOtherOtherName")]
    [UseColumnAttribute]
    [Column("MyOtherName")]
    public int MyThisName { get; set; }
}

Good:

class MyType
{
    [DbValue(Name = "MyOtherOtherName")]
    // without [Column] and [UseColumnAttribute]
    public int MyThisName { get; set; }
}

Another good:

class MyType
{
    // without [DbValue]
    [UseColumnAttribute]
    [Column("MyOtherName")]
    public int MyThisName { get; set; }
}