Wednesday, September 19, 2018

the very specific name ApplicationUser

Ever the technocrat, Valerio De Sanctis suggests on page 163 of his book "ASP.NET Core 2 and Angular 5" that ApplicationUser is by naming convention the best name for a class that inherits from IdentityUser, a base class used by the ASP.NET Identity module. There probably will only be the one class, eh? He has an example of a POCO class for ApplicationUser on pages 162 and 163 and it uses attributes driven by System.ComponentModel.DataAnnotations at what would otherwise seem an innocuous plain Jane class to start out with. Ultimately, this is going to be an Entity Framework Code First class however. Some of the getsetters with the annotations look like so:

[Key]
[Required]
public string Id { get; set; }
 
[Required]
[MaxLength(128)]
public string UserName { get; set; }
 
[Required]
public string Email { get; set; }

 
 

Addendum 9/20/2018: The annotation [DefaultValue(0)] would be for a default value of zero I suppose.

 
 

Addendum 9/23/2018: DefaultValue is in the System.ComponentModel namespace not the System.ComponentModel.DataAnnotations namespace.

No comments:

Post a Comment