Difference between DbSet.Remove and DbContext.Entry(entity).State = EntityState.Deleted

前端 未结 1 936
轻奢々
轻奢々 2021-01-12 01:52

Consider the following entity model:

public class Agreement : Entity
{
    public int AgreementId { get; set; }
    public virtual ICollection

        
相关标签:
1条回答
  • 2021-01-12 02:44

    Ended up solving this by calling the following:

    dbContext.Set<Agreement>().Remove(agreement);
    

    I wanted to get rid of the Agreements property on the DbContext, which is why I was trying to do it with Entry(agreement).State = EntityState.Deleted.

    0 讨论(0)
提交回复
热议问题