Table of Contents

Class RoleBase<TKey>

Namespace
NuvTools.Security.Identity.Models
Assembly
NuvTools.Security.Identity.Models.dll

Represents the base model for application roles within the identity system.

public abstract class RoleBase<TKey> : IdentityRole<TKey> where TKey : IEquatable<TKey>

Type Parameters

TKey

The type of the primary key used for the role (e.g., Guid or int).

Inheritance
RoleBase<TKey>
Inherited Members

Remarks

This abstract class extends IdentityRole<TKey> to provide additional validation, display metadata, and support for storing associated claims in memory.

Constructors

RoleBase()

Initializes a new instance of the RoleBase<TKey> class.

protected RoleBase()

RoleBase(string)

Initializes a new instance of the RoleBase<TKey> class with the specified name.

protected RoleBase(string name)

Parameters

name string

The name of the role.

Properties

Claims

Gets or sets the list of claims associated with this role.

[NotMapped]
public List<KeyValuePair<string, string>>? Claims { get; set; }

Property Value

List<KeyValuePair<string, string>>

Remarks

This property is marked as "NotMapped" since claims are managed through the RoleManager<TRole> API and are not persisted directly in the database.

Name

Gets or sets the display name of the role.

[Display(Name = "Name", ResourceType = typeof(Fields))]
[Required(ErrorMessageResourceName = "XRequired", ErrorMessageResourceType = typeof(Messages))]
[MaxLength(30, ErrorMessageResourceName = "XMustHaveUpToYCharacters", ErrorMessageResourceType = typeof(Messages))]
public override string? Name { get; set; }

Property Value

string

Remarks

This property overrides the base Name property to apply validation and localization-friendly display attributes.