I am having problems with my model and trying to delete records. I have reduced it to try and show the issue I am having
I have a entity called CollectedBags with an Id and name.
I then have a entity called BankingRun which contains a list of CollectedBags
public virtual List<CollectedBags> Bags { get; set; }
This model automatically adds a relationship between the two, and in the database it adds a column to collectedbags to reference the BankingRun.
The problem occurs when I want to delete the BankingRun without affecting the CollectedBags table at all. A CollectedBags record doesn't always belong to a BankingRun. Anything I try to delete a record results in a conflict between the two tables obviously, but my lack of knowledge with entity framework is leaving me stuck without writing some SQL to physically remove the Banking Run id in CollectedBags
public class CollectedBags
{
public long CollectedBagsId { get; set; }
public string Name { get; set; }
}
public class BankingRun
{
public long BankingRunId { get; set; }
public DateTime DateTimeVisited { get; set; }
public virtual List<CollectedBags> Bags { get; set; }
}
I am then trying to delete a BankingRun after its been created with multiple CollectedBags