The DELETE statement conflicted with the REFERENCE constraint > "FK_dbo.VendorDocuments_dbo.VendorModels_VendorId". The conflict occurred in database > "aegisv", table "dbo.VendorDocuments", column 'VendorId'. The statement has been terminated.
Means I have one table of VendorModel which has list of invoicedocument(it is a model with foreign key vendorId of table vendor model). when I am trying to delete Vendor model from database I am getting above exception.
I have tried various things but I haven't resolve same yet.
Have added following code but doesn't worked.
modelBuilder.Entity<VendorDocument>()
.HasRequired(x => x.VendorModel)
.WithMany(u => u.VendorDocumemts)
.WillCascadeOnDelete();
Please any one can help me.. Thank you.