Dotnet
Authentication and Authorization - Registration Part 2

Add Account Domain

PRO

I finished! On to the next chapter

Outline

Demo: Add Account Domain

In Conduit.Data Project

Modify class named Account
  • Remove and Sort usings
  • Add the Table Attribute specifying Accounts as the table name.
Add the following properties
  • Id (int)
  • Email (string)
  • PasswordHash (byte array)
  • PasswordSalt (byte array)
  • Person (Person)
Add the following Attribute to the Id Property
  • key
Add the following Attribute to the Email Property
  • Required
  • StringLength
    • Set the max lenth at 50 (or any length you desire)
Add the following Attribute to the PasswordHash Property
  • Required
  • StringLength
    • Set the max lenth at 128
Add the following Attribute to the PasswordSalt Property
  • Required
  • StringLength
    • Set the max lenth at 128

Here's the code for Conduit.Data.Account.cs:

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Conduit.Data
{
    [Table("Accounts")]
    public class Account
    {
        [Key]
        public int Id { get; set; }

        [Required]
        [StringLength(50)]
        public string Email { get; set; }

        [Required]
        [StringLength(128)]
        public byte[] PasswordHash { get; set; }

        [Required]
        [StringLength(128)]
        public byte[] PasswordSalt { get; set; }

        public Person Person { get; set; }
    }
}