我有一个映射如下:
public class InvoiceDetailMapping : ClassMap<InvoiceDetail>
{
public InvoiceDetailMapping()
{
Id(x => x.DetailId)
.GeneratedBy.Guid();
Map(x => x.Account);
Map(x => x.Credit);
Map(x => x.Debit);
Map(x => x.PayType);
Map(x => x.RowNumber);
References<InvoiceItem>(x => x.Invoice, "InvoiceItemId")
.Cascade.All();
}
}
public class InvoiceItemMapping : ClassMap<InvoiceItem>
{
public InvoiceItemMapping()
{
Id(x => x.RecordId)
.GeneratedBy.Guid();
Map(x => x.BatchId);
Map(x => x.Description);
Map(x => x.DocumentDate);
Map(x => x.DocumentId);
Map(x => x.DocumentType);
Map(x => x.FileId);
Map(x => x.FileName);
Map(x => x.InvoiceAmount);
Map(x => x.LocationCode);
Map(x => x.PayDate);
Map(x => x.PaymentTerms);
Map(x => x.PayNumber);
Map(x => x.PurchaseAmount);
Map(x => x.PurchaseInvoiceAmount);
Map(x => x.InvoiceId);
Map(x => x.Submittable);
Map(x => x.SubmittedBy);
Map(x => x.SubmittedTimeStamp);
Map(x => x.TaxForm1099Amount);
Map(x => x.TroubleClass);
Map(x => x.VendorDocNumber);
Map(x => x.VendorId);
Map(x => x.PersistedTimeStamp)
.CustomType<UtcDateTimeType>()
.Generated.Insert();
HasMany<InvoiceDetail>(x => x.InvoiceDetails)
.Inverse()
.Cascade.All()
.KeyColumn("InvoiceItemId");
}
}
...但是当我将其应用于我的 PostgreSQL 数据库时,它会为 InvoiceDetail 创建以下 SQL:
CREATE TABLE "InvoiceDetail"
(
detailid uuid NOT NULL,
account character varying(255),
credit numeric(19,5),
debit numeric(19,5),
paytype integer,
rownumber integer,
invoiceitemid uuid,
CONSTRAINT "InvoiceDetail_pkey" PRIMARY KEY (detailid ),
CONSTRAINT fkd8588014e9009e93 FOREIGN KEY (invoiceitemid)
REFERENCES "InvoiceItem" (recordid) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
注意ON UPDATE NO ACTION ON DELETE NO ACTION
线。我原以为该Cascade.All()
指令会创建一个ON UPDATE CASCADE ON DELETE CASCADE
DDL。我做错了什么或不完整?