Micro ORM Dapper无法找到类型的关键属性

时间:2016-04-20 11:28:42

标签: dapper dapper-fluentmap

我是Micro-ORM的新手我正在使用dapper流畅的映射和dommel我尝试插入/添加条目但是我遇到了这个错误"找不到类型&#34的关键属性 这是我的代码

        using (IDbConnection con = new MySqlConnection(cnxStr))
        {
            con.Open();
            equipment eqp = new equipment 
            {
                category_id     = 1, 
                barcode         = "DDH-003",
                asset_number    = "45645645", 
                equipment_name  = "DBD Dew", 
                equipment_description = "Thin Can", 
                manufacturer_id = 3, 
                model           = "Blah", 
                serialnumber    = "11111", 
                status          = "Good", 
                service_group   = "SGE", 
                required_pm     = "Yes", 
                service_provider="111", 
                frequency       = 1, 
                department_id   = 1, 
                location_id     = 1, 
                availability    = "Avail", 
                register_id     = 1, 
                supplier_id     = 1, 
                conditionstatus_id = 1, 
                status_id       = 1, 
                utilization_id = 3
            };
            int count = con.Insert<equipment>(eqp); <-- error here
            if (count > 0) 
            {
                MessageBox.Show("Successfully Added", "Successfully Added -:", MessageBoxButtons.OK, MessageBoxIcon.Information); 
            }
            con.Close();

        }

1 个答案:

答案 0 :(得分:0)

Dapper假设您的数据库模型中有一个名为Id的列,除非您另行指定。在这种情况下,另一方面,您正在使用Dapper.Contrib的扩展。为此,您必须在主键上方添加指令onTestFailure