Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/AdaskoTheBeAsT/AdaskoTheBeAsT.Identity.Dapper
Dapper implementation for Microsoft.Extensions.Identity.Stores
https://github.com/AdaskoTheBeAsT/AdaskoTheBeAsT.Identity.Dapper
Last synced: 3 months ago
JSON representation
Dapper implementation for Microsoft.Extensions.Identity.Stores
- Host: GitHub
- URL: https://github.com/AdaskoTheBeAsT/AdaskoTheBeAsT.Identity.Dapper
- Owner: AdaskoTheBeAsT
- License: apache-2.0
- Created: 2022-12-17T18:20:54.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-06T19:46:34.000Z (8 months ago)
- Last Synced: 2024-05-15T14:34:28.770Z (6 months ago)
- Language: C#
- Size: 569 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SecurityCodeScan.config.yml
Awesome Lists containing this project
- RSCG_Examples - AdaskoTheBeAsT.Identity.Dapper
- csharp-source-generators - AdaskoTheBeAsT.Identity.Dapper - ![stars](https://img.shields.io/github/stars/AdaskoTheBeAsT/AdaskoTheBeAsT.Identity.Dapper?style=flat-square&cacheSeconds=604800) ![last commit](https://img.shields.io/github/last-commit/AdaskoTheBeAsT/AdaskoTheBeAsT.Identity.Dapper?style=flat-square&cacheSeconds=86400) - Custom Dapper implementation for Microsoft.Extensions.Identity.Stores (part of ASP.NET Core Identity) (Source Generators / Database / ORM)
README
# AdaskoTheBeAsT.Identity.Dapper
Custom Dapper implementation for Microsoft.Extensions.Identity.Stores using Source Code Generators.
[https://learn.microsoft.com/en-us/aspnet/core/security/authentication/identity-custom-storage-providers?view=aspnetcore-7.0](https://learn.microsoft.com/en-us/aspnet/core/security/authentication/identity-custom-storage-providers?view=aspnetcore-7.0).It allows to customize classes which are used by Microsoft Identity and generate Dapper code for them.
Schema of database needs to be created manually but queries are generated based automatically.
User can change schema from default 'dbo' to any other.
User can also skip NormalizedUserName, NormalizedEmail and NormalizedName columns in database and queries.Sample using nuget within project is available here [Sample](https://github.com/AdaskoTheBeAsT/AdaskoTheBeAsT.Identity.Dapper/tree/main/samples/Sample.SqlServer2).
## Usage
1. In your project add nuget packages
```xml
```1. Add following property groups to your project file
```xml
true
Generated
id
true
```1. Add following item groups
```xml
```1. To your project add following classes which inherits from Microsoft Identity classes
```csharp
using Microsoft.AspNetCore.Identity;namespace Sample.SqlServer;
public class ApplicationRole
: IdentityRole
{
}public class ApplicationRoleClaim
: IdentityRoleClaim
{
}// attribute is optional
// if you want to use your own Id type you can use this attribute
// it is helpful when for example you want to store MSAL user id
// as your id
[InsertOwnIdAttribute]
public class ApplicationUser
: IdentityUser
{
[Column("IsActive")]
public bool Active { get; set; }
}public class ApplicationUserClaim
: IdentityUserClaim
{
}public class ApplicationUserLogin
: IdentityUserLogin
{
}public class ApplicationUserRole
: IdentityUserRole
{
}public class ApplicationUserToken
: IdentityUserToken
{
}
```1. Recompile your project
1. You should see generated files in Generated folder
![Sample output](./doc/output.png)