2.2: Identity Models Setup
Last updated
Last updated
In the ElevenNote.Data assembly, open the IdentityModels.cs
file. Please note that we will be adding a lot of code in the next few steps. (2.2a-IdentityModelsScreenshot.md) Refer to this screenshot to see it all in context:
You will have an error on <Note>
until the beginning of part 3, don't worry about it for now.
Look for the ApplicationDbContext
function.
Underneath the function, but still inside the namespace, create the following IdentityUserLoginConfiguration
class and method. This code will go right above the closing curly brace for the file:
CTRL .
to bring in the using statement needed: using System.Data.Entity.ModelConfiguration;
Now create an IdentityUserRoleConfiguration
class underneath the class you just created
In this class, add the following method
Go back up under the Create()
method that is within the ApplicationDbContext
class
Underneath the Create()
method, but still within the ApplicationDbContext
class, add a Notes
property
You will have an error on <Note>
until the beginning of part 3, don't worry about it for now.
Directly underneath the Notes
property, but still within the ApplicationDbContext
class, type override and then a space.
Auto-complete should provide you with choices, choose OnModelCreating
and hit enter.
Delete the base.OnModelCreating(modelBuilder);
and replace it with the following:
CTRL .
to bring in the using statement needed
Here is all of the code we have added for context:
Next, we'll create the Note entity for our database.