Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Adding a column to AspNetUserRoles table in ASP NET Core 3.0

$
0
0

Hello everybody,
I created the tables through Migration to manage the security of my mvc core project.

aspnetcoreidentity table

I would need to be able toinsert an additional field in the AspNetUserRoles table in order to manage the users already associated with the ADMIN role in a different way, for example I have ADMINs associated with a USA nation and ADMINs associated with another BRAZIL or ADMIN nationassociated with ITALY, but their real role always remains ADMIN.
In practice it is just one more attribute to add when I associate a user with the ADMIN role.



I tried to extend the IdentityUserRole class in this way:

public class AspNetUserRoles : IdentityUserRole<string>
{
    public string Nation { get; set; }
}

but then when I launch the migration script (code-first) in the migration classes no changes are detected!

PM> Add-Migration aspnetuserrolesupdate -Context ApplicationDbContext

this is the result:

public partial class aspnetuserrolesupdate : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {

        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {

        }
    }

as you can see from the product code no changes were found .... cry

In my project I have already inserted fields in the AspNetUsers andAspNetRoles table successfully in this way, but how can I add a third field to theAspNetUserRoles table ???

Thank you all


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>