未经我同意,数据将被修改 [英] Data is modified without my consent
问题描述
public class Division
{
public int Id {get;组;
[必需]
[StringLength(50)]
public string Name {get;组; }
public virtual IList< Department>部门{get;组; }
[Display(Name =Manager)]
public string ManagerId {get;组; }
[ForeignKey(ManagerId)]
public virtual AppUser Manager {get;组; }
public virtual IList< AppUser>用户{get;组;
}
所以该司有一个经理。
当我保持应用程序运行一段时间后,所有相关的管理员都将被删除而无需我做任何事情!
只有关系被删除(ManagerId = null)而不是Id,但它们仍然在Users表中。
任何建议将不胜感激。
(编辑)
谢谢Carl,
我把一个Trigger放在表格上,我注意到,当我离开应用程序运行一段时间时,它会得到更新,然后尝试输入任何页面
当我发布不启用(运行应用程序首次启动迁移)时,问题已解决。
知道确切的原因,但我认为当我离开应用程序运行一段时间,然后进入任何页面,Seed方法再次运行。
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 !
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.
这篇关于未经我同意,数据将被修改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!