How add ASP.NET Core identity to existing Core mvc project?

add asp.net identity to existing mvc project
add asp.net identity to existing database
add asp.net core identity to existing mvc project
asp.net core 3 add identity to existing project
asp.net core 2.1 identity tutorial
asp.net core identity web api
asp.net core 2.2 identity
add identity to asp.net core web api

I have already started my dotnet core mvc project without identity on Mac with CLI and now I want to add this feature. The only option I have known till now is to create a new project by

dotnet new mvc --auth

Is there a better way to add identity to an existing project? I hope there is a 'dotnet new' command.

dotnet add package Microsoft.AspNetCore.Identity 

Adding ASP.NET Identity to an Empty or Existing Web Forms Project , How can I do this manually for an application which was not configured for an individual accounts authentication and authorization ? Adding ASP.NET Core Identity to an Existing Project. Most of the existing documentation for ASP.NET Identity start with selecting “individual user accounts” when creating a new ASP.NET Core project. We already have a project so we need to look at adding ASP.NET Core to an existing project.

According to docs.microsoft.com you can scaffold identity into an existing MVC project with aspnet-codegenerator.

1) If you have not previously installed the ASP.NET Core scaffolder, install it now:

dotnet tool install -g dotnet-aspnet-codegenerator

2) Add a package reference to Microsoft.VisualStudio.Web.CodeGeneration.Design to the project (*.csproj) file. Run the following command in the project directory:

dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet restore

3) Run the following command to list the Identity scaffolder options:

dotnet aspnet-codegenerator identity -h

4) In the project folder, run the Identity scaffolder with the options you want. For example, to setup identity with the default UI and the minimum number of files, run the following command:

dotnet aspnet-codegenerator identity --useDefaultUI

5) The generated Identity database code requires Entity Framework Core Migrations. Create a migration and update the database. For example, run the following commands:

dotnet ef migrations add CreateIdentitySchema
dotnet ef database update

6) Call UseAuthentication after UseStaticFiles:

public class Startup
{

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddMvc();
    }

    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");
            app.UseHsts();
        }

        app.UseHttpsRedirection();
        app.UseStaticFiles();
        app.UseAuthentication(); // <-- add this line
        app.UseMvcWithDefaultRoute();
    }
}

How add ASP.NET Core identity to existing Core mvc project , NET Core 2.1 application as the Identity framework is available in a nuget In this post, find out how to add Identity as UI in ASP. 2.1 and choose either Web Application or Web Application(MVC). Migrate existing ASP.Net  4) In the project folder, run the Identity scaffolder with the options you want. For example, to setup identity with the default UI and the minimum number of files, run the following command: 5) The generated Identity database code requires Entity Framework Core Migrations. Create a migration and update the database.

You can manage this through the NuGet Package Manager:

Tools -> NuGet Package Manager -> Console

$ Install-Package Microsoft.AspNet.Identity.Core

Introducing Identity to the ASP.NET Core Project, It's easy to create a new project with ASP.NET Identity. In this post we look at adding ASP.NET Identity to an existing ASP.NET Core project. ASP.NET Core 2.1 and later provides ASP.NET Core Identity as a Razor Class Library. Applications that include Identity can apply the scaffolder to selectively add the source code contained in the Identity Razor Class Library (RCL). You might want to generate source code so you can modify the code and change the behavior.

Adding ASP.NET Core Identity service to an Existing ASP.NET Core , Today, I would like to show how to add asp.net identity 2.0 into existing mvc project. First, create a mvc project without individual authentication  In this article, we are going to learn about ASP.NET Core Identity implementation in the ASP.NET Core project. ASP.NET Core Identity is the membership system for web applications that includes membership, login and user data. But, it is not just a user store, it is much more than that.

Add Identity as UI in ASP.NET Core 2.1 application, NET Core Identity. ASP.NET Core Identity is basically a membership system is intended to replace the existing membership system of classic ASP.NET. How to create an application using Identity Authentication in ASP. remove user accounts, change the password, add a role to the user, AddMvc(). For Existing Applications. Obviously, adding this functionality can depend on what you’re adding it to. The following was compiled from an ASP.Net Core app created without identity services, and then retrofitted with them. In order to do this, I strongly recommend starting with a dummy app created as above, as there’s a lot of cutting and pasting coming up.

ASP.NET Core Identity to Existing Project, This post is going to take the API project created last week for the Swagger/OpenAPI with NSwag and ASP.NET Core 3 post and replace the generated data with a database using Entity Framework Core. If you want to follow along with this post the files before any changes can be found here .

Comments
  • I look for an explanation why my question was so bad? It was a genuine doubt after all..!
  • I even found the way to the answer. dotnet add package Microsoft.AspNetCore.Identity would do the trick.
  • Starting with ASP.NET Core 2.1, Microsoft.AspNetCore.Identity.UI is also being introduced.
  • This doesn't work with Core projects.