TirsvadCLI Portfolio Library
Loading...
Searching...
No Matches
SeedTestIfNeeded.cs
1using Microsoft.EntityFrameworkCore.Metadata.Builders;
2
4
6
10public 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}
Represents an application user entity for authentication and authorization. Inherits from IdentityUse...
Provides development-time seeding functionality for test users in the database.
static void SeedTestUser(EntityTypeBuilder< ApplicationUser > builder)
Seeds a test ApplicationUser entity into the database using the provided EntityTypeBuilder<TEntity>.