3.1: Data

In this model will we set up our Note.cs class.

3.1: Entity Model

The entity model represents how we will set up data in our database. The properties we add to this class will be added as columns in our SQL table. This class will also be used by the service layer to persist data and query the database. More on that later.

Steps

  1. In the Solution Explorer, right click on ElevenNote.Data.

  2. Select Add -> Class and name it Note.cs.

    Add Note

  3. Make this class public. This will make it accessible to other assemblies.

  4. Add the properties inside of class:

    namespace ElevenNote.Data
    {
     public class Note
     {
         public int NoteId { get; set; }
         public Guid OwnerId { get; set; }
         public string Title { get; set; }
         public string Content { get; set; }
    
         public DateTimeOffset CreatedUtc { get; set; }
    
         public DateTimeOffset? ModifiedUtc { get; set; }
     }
    }
  5. Now, above each of the properties, we need to add data annotations - we'll see more info about data annotations in the next module.

  1. Click on one of the annotations and click on CTRL . to bring in the using statement for the annotations:

    Using statement selection for Annotations

Last updated