Data is modified without my consent

被刻印的时光 ゝ 提交于 2019-12-25 06:55:53

问题


I am using .NET MVC 5 and entity framework I have this model :

public class Division
{
    public int Id { get; set; }

    [Required]
    [StringLength(50)]
    public string Name { get; set; }

    public virtual IList<Department> Departments { get; set; }

    [Display(Name = "Manager")]
    public string ManagerId { get; set; }

    [ForeignKey("ManagerId")]
    public virtual AppUser Manager { get; set; }

    public virtual IList<AppUser> Users { get; set; }
}

So the Division Has a Manager.

When I keep the App running for a while, All related managers are removed without me doing any thing ! Only the relation is removed ( ManagerId = null ) instead of the Id, but they still there in the Users table.

Any suggestions will be appreciated.

(Edit) Thank you Carl,
I put a Trigger on the table divisions, and I noticed that it get updated when I leave the app running for a while and then try to enter any page !


回答1:


The problem was solved when I published without enabling ( running migration with the app first start up ).

I don't know the exact reason but I think when I leave the app running for a while and then enter any page, the Seed method was running again.



来源:https://stackoverflow.com/questions/25875113/data-is-modified-without-my-consent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!