EF 6.1.3
映射
var b = mb.Entity<PAYMENT_INVOICE>();
b.ToTable("T_PAYMENT_INVOICE");
b.HasPrimaryKey(x => x.Id);
b.Property(x => x.OrdersSumm).IsRequired();
b.Property(x => x.MargaSumm).IsRequired();
b.Property(x => x.DeliverySumm).IsRequired();
b.Property(x => x.PaySumm).IsRequired();
b.Property(x => x.CreateDate).IsRequired();
b.Property(x => x.Sended).IsRequired();
b.Property(x => x.LastError).IsOptional();
b.HasOptional(x => x.Payment).WithMany(x => x.Invoices).HasForeignKey(x => x.PaymentId);
b.HasRequired(x => x.Client).WithMany().HasForeignKey(x => x.ClientId);
b.HasRequired(x => x.Purchase).WithMany(x => x.Invoices).HasForeignKey(x => x.PurchaseId).WillCascadeOnDelete(false);
为什么要生成此密钥和列?两者都是平等的。
我删除了列PURCHASE_ID
和FK_dbo.T_PAYMENT_INVOICE_dbo.T_PURCHASE_PURCHASE_Id
。
当我保存PAYMENT_INVOICE
时出现错误:
无效的列名称'PURCHASE_Id'
我不需要第二把钥匙,我的错误是什么?