Skip to content

linq2db/LinqToDB.Identity

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code
This branch is 93 commits ahead, 581 commits behind aspnet:master.

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
ci
November 28, 2017 01:32
December 17, 2022 14:20
February 24, 2023 14:46
December 17, 2020 11:43
January 15, 2016 14:18
August 30, 2020 09:15
October 1, 2020 11:42
December 17, 2022 14:20
November 27, 2017 22:21
May 17, 2017 15:17
July 23, 2018 11:00
ci
November 28, 2017 01:35
May 17, 2017 15:17
May 17, 2017 15:17
October 1, 2020 11:42

LinqToDB Identity store provider for ASP.NET Core Identity

  • Current build status Build status
  • Master build status Build status

Feeds

  • Release builds can be found on NuGet
  • MyGet
    • V2 https://www.myget.org/F/linq2db/api/v2
    • V3 https://www.myget.org/F/linq2db/api/v3/index.json

Usage

Install package:

PM> Install-Package linq2db.Identity

In general this is the same as for Entity Framework, just call AddLinqToDBStores instead of AddEntityFrameworkStores in your Startup.cs like here:

services.AddIdentity<ApplicationUser, IdentityRole>(options => {
    options.Cookies.ApplicationCookie.AuthenticationScheme = "ApplicationCookie";
    options.Cookies.ApplicationCookie.CookieName = "Interop";
    options.Cookies.ApplicationCookie.DataProtectionProvider = DataProtectionProvider.Create(new DirectoryInfo("C:\\Github\\Identity\\artifacts"));
})
    .AddLinqToDBStores(new DefaultConnectionFactory()) //here
    .AddDefaultTokenProviders();

The main difference with Entity Framework Core storage provider are:

  • We do not use hardcoded classes - interfaces like IIdentityUser<TKey> are used (but yes, we do have default implementation)
  • Data connection factory is used for calling to database

Identity and other mapping

We do not use any default mapping attributes on default POCOs (IdentityUser, IdentityRole and so on). This is because this types can be used on different environvents.

If in some reason you prefere using default POCOs you can use fluent mapping in your Startup.cs to define needed attributes.

For example to treat Id as identity:

    LinqToDB.Mapping.MappingSchema.Default.GetFluentMappingBuilder()
        .Entity<IdentityUser<int>>()
        .HasIdentity(_ => _.Id);

Special

All source code is based on original Microsoft Entity Framework Core storage provider for ASP.NET Core Identity.

Tests and sample are just adopted for using LinqToDB. For inmemory storage tests SQLite inmemory database is used.

About

ASP.NET Core Identity provider that uses LinqToDB.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 97.2%
  • PowerShell 2.0%
  • Shell 0.8%