【问题标题】:Does Dapper.Contrib support inserts to tables that use Identity columns?Dapper.Contrib 是否支持插入到使用 Identity 列的表中?
【发布时间】:2016-09-14 13:28:32
【问题描述】:

我正在使用 Dapper.Contrib v1.50.0 和 Dapper v1.50.2。我在用 [Key] 注释的类中有 key 属性,而在数据库中,该列是 Identity。当我尝试插入 Sql Server 时,会抛出一个错误,即无法将值插入到 Identity 列中。 Dapper.Contrib 是否支持插入到使用 Identity 列的表中?

public class Product {
        [Key]
        public int ProductId {get; set;}
        public string BrandCode { get; set; }
        public bool TwoDScanRequired {get; set;}
        public string CommodityCode {get; set;}
        public string Description {get; set;}
   }

【问题讨论】:

    标签: sql-server dapper


    【解决方案1】:

    我意识到我接受了使用 System.Component.Model.DataAnnotations 的默认值,它应该使用 Dapper

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-13
      • 1970-01-01
      相关资源
      最近更新 更多