Invalid object name 'dbo.AspNetUsers' in Asp.NET MVC 5 Entity Framework

后端 未结 7 526
悲哀的现实
悲哀的现实 2020-12-06 02:33

If you have an existing database, and you want to include ASP.NET Identity tables to it, you can face this error. You may not know how to integrate [AspNetRoles], [A

7条回答
  •  南方客
    南方客 (楼主)
    2020-12-06 03:23

    I go through same issue.
    sometime user create customize class for membership hence asp.net dont create AspNetUsers table
    example :

    public class Member : IdentityUser
    {
        Public int MemberID { get; set; }
        public string Name { get; set; }
        public string Family { get; set; }
        public string Password { get; set; }
    
    }  
    

    in this scenario ASP.NET create Member table and when user want to authenticate,ASP.NET search for AspNetUsers and did not find this table. this problem solved with add TableAttribute in begin of customized class

    [Table("AspNetUsers")]
    public class Member : IdentityUser
    {
        Public int MemberID { get; set; }
        public string Name { get; set; }
        public string Family { get; set; }
        public string Password { get; set; }
    
    }
    

提交回复
热议问题