Dapper Contrib - Data Annotation - ExplicitKey

Description

Specifie the property is a key that is NOT automatically generated by the database.

[Table("InvoiceDetail")]
public class InvoiceDetailContrib
{
[ExplicitKey]
public int InvoiceID { get; set; }

public string Detail { get; set; }
}

using (var connection = My.ConnectionFactory())
{
connection.Open();

var invoice = new InvoiceContrib {Kind = InvoiceKind.WebInvoice, Code = "Insert_Single_1"};
connection.Insert(invoice);

var invoiceDetail = new InvoiceDetailContrib {InvoiceID = invoice.InvoiceID, Detail = "Insert_Single_1"};
connection.Insert(invoiceDetail);
}