小编syp*_*tha的帖子

EntityFramework中的MVC5 Identity +多个上下文

我有一个MVC 5应用程序,它使用默认身份验证.用户配置文件是我们模型的一部分,这意味着有几个类具有UserInfo的外键.有2个DbContext,一个用于模型,另一个用于UserInfo.

 public class ApplicationDbContext : IdentityDbContext<UserInfo>
    {
        public ApplicationDbContext()
            : base("Profile")
        {
        }

    }



 public class UserInfo : IdentityUser
        {
            public UserInfo ()
            {
                LibraryItems = new List<LibraryItem>();
                if (UserGroup == UserGroupEnum.ANALYST)
                {
                    Companies = new List<Company>();
                }
                DateCreate = DateTime.Now;
                DateUpdate = DateTime.Now;
                DateDelete = DateTime.Now;
            }

            [DisplayColumnInIndex]
            [DisplayName("Is Active ?")]
            public bool IsActive { get; set; }

            [Timestamp]
            public byte[] RowVersion { get; set; }

            //[ValidateFile(ErrorMessage = "Please select a PNG image smaller than 1MB")]
            //[DisplayFormat(ApplyFormatInEditMode = …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework asp.net-mvc-5 asp.net-identity

2
推荐指数
1
解决办法
2219
查看次数