dotConnect for Oracle Documentation
In This Topic
    Using Entity Framework Core Implementation of ASP.NET Core Identity for Oracle
    In This Topic

    ASP.NET Core Identity is a new system of user authentication and authorization for ASP.NET Core. You can read more on ASP.NET Identity in Microsoft documentation.

    dotConnect for Oracle enables you to employ an implementation of ASP.NET Core Identity for Oracle database using Entity Framework Core functionality in your web applications. This allows you to use such ASP.NET Core Identity benefits as unit-testable user authentication system, social login support, OWIN integration, etc. This tutorial demonstrates creating an Entity Framework implementation of ASP.NET Core Identity.

    To complete this tutorial you need Visual Studio 2017 or higher. You may also use Visual Studio 2015 with NET Core tools Preview 2 for Visual Studio 2015 installed, but in this case you may need to install newer versions of Entity Framework Core-related NuGet packages to the project.

    If you use the trial version of dotConnect for Oracle, you will also need to install dotConnect for Oracle in order to get the corresponding trial license key file. See more details about technical licensing in .NET Core applications using dotConnect for Oracle in the Licensing .NET Standard (.NET Core) Projects topic.

    In order to create an ASP.NET Core application using dotConnect for Oracle for storing identity information, perform the following steps:

    1. FVisual Studio 2019, or Visual Studio 2022: Select C# in the left drop-down list, then select Windows in the middle one, and Web in the right. Then select ASP.NET Core Web Application, click Next, and then click Create.

      Add New Project dialog box in Visual Studio 2019

      For Visual Studio 2017: In the Add New Project dialog box expand Visual C# on the left, then Web, and then select ASP.NET Core Web Application (.NET Core). Name your project, for example, "AspNetCore_Identity_Application" and then click OK.

      Add New Project dialog box in Visual Studio 2017

    2. In the next dialog box, select the Web Application (Model-View-Controller) template.

      New ASP.NET Project dialog box in Visual Studio 2019
      Visual Studio 2019

      New ASP.NET Project dialog box in Visual Studio 2017
      Visual Studio 2017

    3. FVisual Studio 2019, or Visual Studio 2022, under Authentication, click Change. For Visual Studio 2017, click Change Authentication.

    4. Then select Individual User Accounts as authentication method and click OK.
    5. Execute the following command in the Package Manager Console:

      install-package Devart.Data.Oracle.EFCore
    6. In the appsettings.json file of your project, replace the default connection string with your Oracle one. For example:

        "ConnectionStrings": {
          "DefaultConnection": "User Id=Scott;Password=tiger;Data Source=Ora;"
        },
      	

      If you purchased dotConnect for Oracle, add your license key to the connection string as the License Key connection string parameter.

    7. In the Startup.cs file of the application, replace

      	options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
      	

      with

      	options.UseOracle(Configuration.GetConnectionString("DefaultConnection")));
      	
    8. In the Solution Explorer open the Data\Migrations folder and delete all its content.
    9. Execute the following command in the Package Manager Console:

      add-migration CreateIdentitySchema -OutputDir Data\Migrations
    10. Execute the following command in the Package Manager Console:

      update-database

    Checking Application

    Now we can run our application and check if everything works correctly.

    1. Run the application by pressing CTRL+F5.

      Home page
    2. Switch to the Register tab on the top of the page.

      Registration page
    3. Enter a new Email and password to the corresponding boxes and click the Register button.
    4. The new user is now registered and logged in, and the ASP.NET Identity tables are created in the Oracle database.

      User is registered
    5. After this you may use an appropriate database tool to connect to the database where the user data is stored and verify that the data is stored correctly.

    See Also

    Using Entity Framework Implementation of ASP.NET Identity 1 for Oracle  | Using Entity Framework Implementation of ASP.NET Identity 2 for Oracle  | Using ADO.NET Implementation of ASP.NET Identity 1 for Oracle  | Using ADO.NET Implementation of ASP.NET Identity 2 for Oracle