1

I created asp.net core project with Authentication -> individual user accounts. I created all the roles and authorised their pages. It is working but i had to uprage the project, adding two more tables. The first table is connected with the second. And the second must be connected with the scaffolded user table. I tried making the relations with OnModelcreating in DbContext but it doesn’t work

1 Answer 1

1

According to your description, if you want to modify the identity table, I suggest you could refer to below steps:

1.Add the new model: e.g:

public class NewTestModel
{
    public int Id { get; set; }
    // This is used to make one to one relationship to identity user
    public IdentityUser user { get; set; }
}

2.Modify the dbcontext:

public class ApplicationDbContext : IdentityDbContext
{
    public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
        : base(options)
    {
    }


    public DbSet<NewTestModel> newTestModels { get; set; }
        

}

3.Open the package management console and run below codes:

Add-Migration Modify1


update-database

enter image description here

Result:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.