How to Use AspNet.Identity core in My Sql database

前端 未结 4 1947
你的背包
你的背包 2021-02-06 07:17

I am developing one application using asp dot net core 2 using MySql database.Please help me How can i use Asp Net Identity in

4条回答
  •  轮回少年
    2021-02-06 07:35

    I am late to this answer but, this developer has put the whole solution nicely, in this repository.

    https://github.com/jasonsturges/mysql-dotnet-core

    Putting the relevant code blocks here.

    protected override void OnModelCreating(ModelBuilder builder)
    {
        base.OnModelCreating(builder);
    
        builder.Entity(entity => entity.Property(m => m.Id).HasMaxLength(127));
        builder.Entity(entity => entity.Property(m => m.ConcurrencyStamp).HasColumnType("varchar(256)"));
    
        builder.Entity>(entity =>
        {
            entity.Property(m => m.LoginProvider).HasMaxLength(127);
            entity.Property(m => m.ProviderKey).HasMaxLength(127);
        });
    
        builder.Entity>(entity =>
        {
            entity.Property(m => m.UserId).HasMaxLength(127);
            entity.Property(m => m.RoleId).HasMaxLength(127);
        });
    
        builder.Entity>(entity =>
        {
            entity.Property(m => m.UserId).HasMaxLength(127);
            entity.Property(m => m.LoginProvider).HasMaxLength(127);
            entity.Property(m => m.Name).HasMaxLength(127);
        });
    }
    

    This is tested by me on a project i was working on at the time of posting this answer.

提交回复
热议问题