Dapper 사용시 key/explicitKey

Dapper를 사용할 때

insert시 pk를 자동으로 채워주려면 해당 변수를 [Key] 로 해줘야함 

 

ex) 

public class ItemEntity
{
  [Key]
  public long ItemIdx {get;set;}

  public long InsertToDB()
  {
      conn.Insert(this);
      return ItemIdx;
  }
}

 

- explicitKey키로 어트리뷰트를 하면 위의 방법은 적용되지 않음

 

[추가 + ]

[key] : "데이터베이스에서 자동으로 생성되는 키로 속성 지정"으로 정의 ( Auto Increment)
[Explicti Key] :  키는 키인데 자동 증가 하지 않는 컬럼 

https://stackoverflow.com/questions/49428967/dappers-explicitkey-attribute-whats-the-purpose\