ASP.NET ID 2 to 3

That's right, therefore .. I think I'm confused !!

I have several ASP.NET MVC 5 sites running using ASP.NET Identity 2.1, and everything is fine. I am creating a new MVC 6 site and I would like users to use the existing credentials that they use for other systems. I have already tried the following:

  • Migrating an ASP.NET database with an identifier of 2 in 3 (says that it cannot, since the tables already exist, I thought it would completely transfer users)
  • I tried to get MVC 6 to work with ASP.NET Identity 2.1 and failed.

I'm just wondering what my options are, since the documentation is not very good in the new version, I understand that there are DDL changes in the database, but I kind of hoped that my MVC 5 websites would carry over like with the database .NET Identity 3 Data Backward Compatible with 2.1.

My other option is to upgrade MVC 5 applications to use Identity 3, which, in turn, I believe that they should upgrade to MVC 6, for which I really have no resources or you have a completely new Identity database (which seems least controversial option).

Any opinions would be helpful, no doubt I missed some details, so happy to fill in the blanks if anyone has any further questions about customization.

+5
source share
2 answers

I did the same, its a lot of effort and you have to do db migrations, but first

New ASP Identity V3 Tables and Migration

Tables and ASP Identity V3 Migration

New ASP Identity V3 Fields

Fields inside the user table, you can expand this, see below

Setting up tables In Startup.cs and change services.AddIdentity

services.AddIdentity<ApplicationUser, IdentityRole<int>>() .AddEntityFrameworkStores<ApplicationDbContext, int>() .AddDefaultTokenProviders(); 

In ApplicationContext.cs and change the class to the next signature.

  public class ApplicationDbContext : IdentityDbContext<ApplicationUser, IdentityRole<int>, int> 

In ApplicationUser.cs and change the class to the next signature.

 `public class ApplicationUser : IdentityUser<int> {...}` 
  • Given all the changes, it was easier for me to delete everything in the migration (except migrations). Go to the project directory on the command line and enter / add migration so dotnet ef migrations add MyDatabaseHere -o Data\Migrations . (-o Option - specify the target folder, not the root folder)
  • for any migration problems, I would just reset the database and deploy it again.
  • or you can automate with this I have not tried this

I have two migration scenarios from EF, I was not sure why ... but for more links from github links 1 and 2

+2
source

Deploying IdentityServer3, it can connect directly to an existing ASP.Net Identity EF database. Then use other sites like oAuth clients that are MVC 5 and / or MVC 6, it does not matter because all they will do is pass secure tokens back and forth between your IdentityServer3 site.

+2
source

Source: https://habr.com/ru/post/1247593/


All Articles