Skip to content

Commit d630c29

Browse files
Provide Microsoft.AspNetCore.Identity.EntityFrameworkCore package README (#57537)
1 parent 439510d commit d630c29

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
## About
2+
3+
`Microsoft.AspNetCore.Identity.EntityFrameworkCore` utilizes Entity Framework Core to provide functionality enabling the storage of user, role, and other identity-related data in a database.
4+
5+
## Key Features
6+
7+
* Provides user and role management
8+
* Enables secure authentication and authorization mechanisms
9+
* Allows storage and validatation of user passwords using hashing
10+
* Tracks email confirmation for user account validation
11+
* Tracks two-factor authentication to provide an extra layer of security
12+
* Tracks failed login attempts to help protect against brute-force attacks enabling locking out user accounts after multiple failed login attempts
13+
* Uses claims to define fine-grained access control policies
14+
* Seamlessly integrates with Entity Framework Core for data storage and retrieval
15+
16+
## How to Use
17+
18+
To use `Microsoft.AspNetCore.Identity.EntityFrameworkCore`, follow these steps:
19+
20+
### Installation
21+
22+
```sh
23+
dotnet add package Microsoft.AspNetCore.Identity.EntityFrameworkCore
24+
```
25+
26+
### Configuration
27+
28+
Add the following code to the `Program.cs` of your ASP.NET Core app:
29+
30+
```csharp
31+
builder.Services.AddDbContext<ApplicationDbContext>(options =>
32+
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));
33+
34+
builder.Services.AddDefaultIdentity<ApplicationUser>()
35+
.AddEntityFrameworkStores<ApplicationDbContext>();
36+
```
37+
38+
You can replace `ApplicationDbContext` with your own database context class derived from `IdentityDbContext` and `ApplicationUser` with your own user class containing additional properties derived from `IdentityUser`.
39+
40+
Make sure to [configure the connection string](https://learn.microsoft.com/ef/core/miscellaneous/connection-strings#aspnet-core) via "ConnectionStrings:DefaultConnection" (or whatever you rename it to) so it can connect to your database.
41+
42+
## Main Types
43+
44+
The main types provided by `Microsoft.AspNetCore.Identity.EntityFrameworkCore` include:
45+
46+
* `IdentityDbContext`: Provides the database context for storing and managing user, role, and other identity-related data
47+
* `IdentityUserContext`: Provides methods and properties for querying and manipulating user information
48+
* `RoleStore`: Provides methods for creating, updating, and deleting roles, as well as querying and managing role-related data
49+
* `UserStore`: Provides methods for creating, updating, and deleting users, as well as querying and managing user-related data
50+
* `UserOnlyStore`: Provides methods for creating, updating, and deleting users, as well as querying and managing user-related data for users without roles
51+
52+
## Additional Documentation
53+
54+
For additional documentation and examples, refer to the [official documentation](https://learn.microsoft.com/aspnet/core/security/authentication/identity) on ASP.NET Core Identity.
55+
56+
## Feedback & Contributing
57+
58+
`Microsoft.AspNetCore.Identity.EntityFrameworkCore` is released as open-source under the [MIT license](https://licenses.nuget.org/MIT). Bug reports and contributions are welcome at [the GitHub repository](https://github.com/dotnet/aspnetcore).

0 commit comments

Comments
 (0)