Microsoft Identity how to update database to new table design - c#

I have a webforms application written in asp.net v4.7 that uses Microsoft Identity which it created the relevant tables on our SQL Server.
We are now using Razor Pages with .NET Core for all new applications. I've created a new Razor Pages application and need to use Microsoft Identity once again with the same tables as the other applications. I've created the identity part but it comes up with an error that certain columns are missing from the tables on the SQL Server when I try to login.
I've tried using PM and doing an update-database but it comes up with an error saying the tables already exist. How do I update these tables to include the new columns that the latest Microsoft Identity needs please?
Many thanks

As far as I know, the asp.net core default identity table structure is not as same as asp.net's so there is no way to directly use the old table's data.
If you want to migrate from the asp.net to asp.net core identity, I suggest you could refer to this article.

Related

Cookie Sharing Between ASP.Net Core 2.2 and ASP.Net 4.6, with ASP.Net Identity

I have followed this article to implement cookie sharing between an ASP.Net Core 2.2 MVC app with ASP.Net Core Identity, and an ASP.Net Framework 4.6 MVC app with ASP.Net Identity:
https://learn.microsoft.com/en-us/aspnet/core/security/cookie-sharing?view=aspnetcore-2.2
The article mentions that a common user database must be used:
"Use a common user database
Confirm that the identity system for each app is pointed at the same user database. Otherwise, the identity system produces failures at runtime when it attempts to match the information in the authentication cookie against the information in its database."
I've noticed that there are some slight schema differences between the ASP.Net Core Identity tables--AspNetUsers tables, etc.--and the ASP.Net (standard) Identity tables.
The 'common user database' I'm using contains the ASP.Net Core version of the Identity tables.
I've not been able to get cookie sharing to fully work, because the column, "LockOutEndDateUtc", which was a part of the prior version of the AspNetUsers table, is no longer in the table--specifically, the column is now "LockoutEnd".
Because of the missing LockOutEndDateUtc column, an error is thrown when calling Authentication.User.Identity.GetUserId() from the ASP.Net 4.6 application, which is pointed to the common user database that contains the ASP.Net Core version of the Identity tables. Based on this, I wonder if there might be additional issues when sharing cookies between ASP.Net 4.6 and ASP.Net Core 2.2 apps.
Has anyone else run in to this problem? And/or what is the best way to proceed?
(I can add the column to the AspNetUsers table and get past the issue; however, I would imagine that there is a proper/common way to address this.)

How to use a new SQL Server database for ASP.NET MVC default web application

First of all a similar question was asked on below link but since there is no satisfied and accepted answer I am asking again.
asp.net mvc modify default authentication system
When I create a default ASP.NET MVC application in Visual Studio 2015, there is a default authentication system. It has also a database with tables. What I want to do is using my own database for the default authentication system, so I can integrate it to an application easily. I can create same tables in my database for it.
I tried to find some references to tables like AspNetUsers in the code but I couldn't find anything.
I always created database first and create model from it automatically in ASP.NET MVC. So always there is reference for my tables in my code. But default ASP.NET MVC application seems different.
Which part of the code I should modify and how?
And also why couldn't I find any reference to tables in the code?
The tables are created by default when creating the project because of authentication.
If changed like this This table can not be created.
If you want to use authentication, you can use Asp.net Identity.

How to migrate ASP.NET Web Forms application from Membership to ASP.NET Identity 2.0?

I have an application which is in .NET Framework version 4.5. It uses Web Forms and EntityFramework 6.1.1.
The EntityFramework's Context object is of type ObjectContext. I'm using ASP.NET Membership(the MembershipProvider is customized i.e Custom Membership) for managing the user account related operations.
I want to migrate my Web Forms application to ASP.NET Identity.
According to http://www.asp.net/identity/overview/migrations/migrating-an-existing-website-from-sql-membership-to-aspnet-identity article I think I have to do the following things to migrate to the ASP.NET Identity:
Convert the ObjectContext to DbContext(and correct the related codes)
Create the new tables needed for ASP.NET Identity and do the data migration.
Redefine the account section codes and other dependent codes as needed to match the business logic.(optional)
I have few questions in my mind:
1) I have customized the membership User table and there are several custom foreign keys associated with the User table. Will it still be feasible to migrate to the Identity system without losing any data?
2) As I'm using EntityFramework so DbContext is needed to migrate to Identity system. Can I use ObjectContext for ASP.NET Identity migration?
3) I'm NOT using all the Membership tables as listed at http://i1.asp.net/media/48109/image006.png?cdn_id=2014-11-11-001. (i.e aspnet_Applications, aspnet_Membership, aspnet_Paths, aspnet_PersonalizationAllUsers, aspnet_PersonlizationPerUser, aspnet_Profile, aspnet_Roles, aspnet_SchemaVersions, aspnet_Users, aspnet_UsersInRoles, aspnet_WebEvent_Events)
But I am using Application, User, Role, UserInRole, Profile tables only. Can I still migrate these table in order to use the ASP.NET Identity?
I'm ready to provide more information you may need to understand my current scenario.
I'm looking for the correct steps to migrate to Identity, any caution I need to take care, any hurdles I will face? Any help is highly appreciated.
Dave Paquette wrote this http://www.davepaquette.com/archive/2013/12/30/so-you-inherited-an-asp-net-web-forms-application.aspx
This may be the answer to your problem. Once you have integrated your Web Forms project to MVC, there are plenty of guides online to integrate the new Identity 2.0.

ASP.NET MVC 4, Entity Framework 5 database-first role management and membership integration in same database

I am new to ASP.NET MVC 4 and Entity Framework. I searched for this on google but I didn't get it may be it is my fault.
I am creating new application using previous database. I want to create user account with different roles and access
I want to use same structure for role management which is generated by ASP.NET MVC 4, but it generates different database for that, I don't want in different database, I want to include in same/my database.
Please anyone answer me how to integrate that structure in my database so that I can use same functionality through my database or it is possible to do in database first?
Please help me I am working on it from last 4 days.

Convert Existing Application from using sqlmembership to simplemembership

I have been scouring the internet trying to find a solution to this problem. I have altered the role and membership providers to use SimpleMembership, but it is still referencing the old ("aspnet_XXX") tables. I have found this solution, but it seems like it is only dealing with the user data and moving it over to the new tables. Maybe I'm just reading it wrong. Anyone have any advise on the matter?
If you haven't gone deep, I would to suggest to convert to new ASP.Net Identity comes with MVC 5.
Microsoft has replaced SimpleMembership with ASP.Net Identity.
Introducing ASP.NET Identity – A membership system for ASP.NET applications
Forms authentication using ASP.NET Identity & VS 2013 Preview

Categories