Upgraded to MS Identity Core 2.0 and EF6.1 and login fails: Invalid column name 'Email'

丶灬走出姿态 提交于 2020-01-24 08:40:38

问题


I went to the Manage NuGet Package option and updated all the packages. I'm not using much: Linq-to-EF 6.1 and the packages needed to make MS Identity work. However, something broke because now when I go to log in, I get an error

Exception Details: System.Data.SqlClient.SqlException: Invalid column name 'Email'.
Invalid column name 'EmailConfirmed'.
Invalid column name 'PhoneNumber'.
Invalid column name 'PhoneNumberConfirmed'. //and so on

The exception looks like this:

What might have caused this and how do I fix and prevent this from happening again when all I did was just update the NuGet packages?

Thanks.

Edit: I resolved this issue by totally removing the database; the app recreated a new DB with the necessary columns. I was able to do that because the app is still in dev and no real user data was involved. However, I'm still interested in this issue because when new updates will be released, I want to make sure I don't have to throw away the current DB.


回答1:


I solved this for my application by removing the DefaultConnection connection string. If you have DefaultConnection and MySpecialConnection in your config file, ASP.net identity seems to use DefaultConnection.




回答2:


Sounds like you would need to create your own user object with the additional fields you want that are not provided by the base object. That would then need to match the table in the database.

Then you use that new user object every time you use the usermanager.

var mgr = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>());

  public class ApplicationUser : IdentityUser
    {
         //my custom fields
        public string Email { get; set; }

}

Hope that helps



来源:https://stackoverflow.com/questions/23328257/upgraded-to-ms-identity-core-2-0-and-ef6-1-and-login-fails-invalid-column-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!