26 lines
660 B
C#
26 lines
660 B
C#
using Entities.Contracts;
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace TechHelper.Context.Configuration
|
|
{
|
|
|
|
public class RoleConfiguration : IEntityTypeConfiguration<IdentityRole<Guid>>
|
|
{
|
|
public void Configure(EntityTypeBuilder<IdentityRole<Guid>> builder)
|
|
{
|
|
builder.HasData(
|
|
Enum.GetValues(typeof(UserRoles))
|
|
.Cast<UserRoles>()
|
|
.Select(roleEnum => new IdentityRole<Guid>
|
|
{
|
|
Id = Guid.NewGuid(),
|
|
Name = roleEnum.ToString(),
|
|
NormalizedName = roleEnum.ToString().ToUpper()
|
|
})
|
|
.ToArray());
|
|
}
|
|
}
|
|
}
|