TirsvadCLI Portfolio Library
Loading...
Searching...
No Matches
SeedTestIfNeeded.cs
1
using
Microsoft.EntityFrameworkCore.Metadata.Builders;
2
3
using
TirsvadCLI.Portfolio.Domain.Entities
;
4
5
namespace
TirsvadCLI.Portfolio.Infrastructure.Data.Configurations.SeedsDevelopment
;
6
10
public
class
SeedTestIfNeeded
11
{
29
public
static
void
SeedTestUser
(EntityTypeBuilder<ApplicationUser> builder)
30
{
31
// Precomputed hash for password 'Test@1234' using ASP.NET Core Identity v7+ (for ApplicationUser)
32
// If you change the password, recompute the hash using the same Identity version and user properties.
33
ApplicationUser
user =
new
()
34
{
35
Id = Guid.Parse(
"11111111-1111-1111-1111-111111111111"
),
36
UserName =
"testuser"
,
37
NormalizedUserName =
"TESTUSER"
,
38
Email =
"testuser@example.com"
,
39
NormalizedEmail =
"TESTUSER@EXAMPLE.COM"
,
40
EmailConfirmed =
true
,
41
SecurityStamp =
"11111111-1111-1111-1111-111111111112"
,
42
ConcurrencyStamp =
"11111111-1111-1111-1111-111111111113"
,
43
PasswordHash =
"AQAAAAEAACcQAAAAEJQwQwQwQwQwQwQwQwQwQwQwQwQwQwQwQwQwQwQwQwQwQwQwQwQwQwQwQwQwQwQwQw=="
// Hash for password 'Test1234#'
44
};
45
46
_ = builder.HasData(user);
47
}
48
}
TirsvadCLI.Portfolio.Domain.Entities.ApplicationUser
Represents an application user entity for authentication and authorization. Inherits from IdentityUse...
Definition
ApplicationUser.cs:13
TirsvadCLI.Portfolio.Infrastructure.Data.Configurations.SeedsDevelopment.SeedTestIfNeeded
Provides development-time seeding functionality for test users in the database.
Definition
SeedTestIfNeeded.cs:11
TirsvadCLI.Portfolio.Infrastructure.Data.Configurations.SeedsDevelopment.SeedTestIfNeeded.SeedTestUser
static void SeedTestUser(EntityTypeBuilder< ApplicationUser > builder)
Seeds a test ApplicationUser entity into the database using the provided EntityTypeBuilder<TEntity>.
Definition
SeedTestIfNeeded.cs:29
TirsvadCLI.Portfolio.Domain.Entities
Definition
ApplicationUser.cs:5
TirsvadCLI.Portfolio.Infrastructure.Data.Configurations.SeedsDevelopment
Definition
SeedTestIfNeeded.cs:5
src
TirsvadCLI.Portfolio.Infrastructure
Data
Configurations
SeedsDevelopment
SeedTestIfNeeded.cs
Generated by
1.15.0