未经我同意,数据将被修改 [英] Data is modified without my consent

查看:105
本文介绍了未经我同意,数据将被修改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用.NET MVC 5和实体框架我有这个模型:

  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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆