0

I have two tables. One contains binary data and the other contains the metadata. I am attempting to delete the entire row from both tables, but keep getting the error:

Invalid data encountered. A required relationship is missing.
Examine StateEntries to determine the source of the constraint violation.

The rest of the info is not very helpful. Here is my code currently.

var attachment = _attachmentBinaryRepository.Single(w => w.Id == id);
                _attachmentBinaryRepository.Delete(attachment);
                _unitOfWork.Commit();
                return true;

I was handed this project, but understand the basics of table-splitting. I am just lost in regard to deleting both. I assume, this code is just trying to delete from the one table, but on the one containing the binary data.

Anyone have suggestions?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
PFranchise
  • 6,642
  • 11
  • 56
  • 73
  • This problem seems to be related - see if that helps http://stackoverflow.com/questions/8170975/entity-framework-split-table-delete. – wlabaj Aug 06 '12 at 20:06
  • I was looking at that example earlier today, and perhaps it is my inexperience with EF, but I was not able to apply that solution to my problem. I will keep attempting to though. – PFranchise Aug 06 '12 at 20:19

1 Answers1

1

I don't have the code with me, but I ended up fixing this by retrieving corresponding rows from all of the tables in the relationship. The rows then delete without any trouble.

PFranchise
  • 6,642
  • 11
  • 56
  • 73