问题
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