Upgraded to MS Identity Core 2.0 and EF6.1 and log

2019-06-26 07:24发布

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: enter image description here

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.

2条回答
混吃等死
2楼-- · 2019-06-26 08:03

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.

查看更多
叛逆
3楼-- · 2019-06-26 08:03

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

查看更多
登录 后发表回答