Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何删除ASP.NET Identity中与其他实体具有可选关系的用户_C#_Asp.net Mvc_Entity Framework_Asp.net Identity - Fatal编程技术网

C# 如何删除ASP.NET Identity中与其他实体具有可选关系的用户

C# 如何删除ASP.NET Identity中与其他实体具有可选关系的用户,c#,asp.net-mvc,entity-framework,asp.net-identity,C#,Asp.net Mvc,Entity Framework,Asp.net Identity,我正在创建一个MVC5应用程序,并使用Identity Framework进行身份验证。IdentityUser与内容实体具有一对多的可选关系: public class Content { public int Id { get; set; } public string Title { get; set; } public string CreatedById { get; set; } public AppUser CreatedBy { get;

我正在创建一个MVC5应用程序,并使用Identity Framework进行身份验证。IdentityUser与内容实体具有一对多的可选关系:

public class Content
{
    public int Id { get; set; } 
    public string Title { get; set; }    
    public string CreatedById { get; set; }
    public AppUser CreatedBy { get; set; }

}

public class AppUser : IdentityUser
{
    public ICollection<Content> Contents { get; set; }
}
然后我从我的控制器调用它,如下所示:

await UserManager.MyDeleteUserAsync(user, HttpContext.GetOwinContext());
这是因为它将内容加载到内存中,以便Entity Framework可以在保存之前将外键设置为null


使用Entity Framework的UserManager的内置功能实现这一点的正确方法是什么?

可能吗?谢谢,我来看看。可能吗?谢谢,我来看看。
await UserManager.MyDeleteUserAsync(user, HttpContext.GetOwinContext());