Skip to content

Instantly share code, notes, and snippets.

@vpetkovic
Last active June 8, 2020 00:59
Show Gist options
  • Save vpetkovic/f0edc60f4a0b693dddf731f5f1286c7a to your computer and use it in GitHub Desktop.
Save vpetkovic/f0edc60f4a0b693dddf731f5f1286c7a to your computer and use it in GitHub Desktop.
NETCore 3.1
using IdentityServer.Model;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
namespace IdentityServer.Data
{
public class AppDbContext : IdentityDbContext<ApplicationUser>
{
public AppDbContext(DbContextOptions<AppDbContext> options)
: base(options)
{
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);
}
}
}
using Microsoft.AspNetCore.Identity;
namespace IdentityServer.Model
{
public class ApplicationUser : IdentityUser
{
public string FirstName { get; set; }
public string LastName { get; set; }
public bool IsActive { get; set; }
}
}
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<AppDbContext>(config =>
{
config.UseMySQL(_config.GetConnectionString("Default"), sql => sql
.CharSetBehavior(CharSetBehavior.NeverAppend))));
});
services.AddIdentity<ApplicationUser, IdentityRole>(options => options.SignIn.RequireConfirmedAccount = false)
.AddEntityFrameworkStores<AppDbContext>()
.AddDefaultTokenProviders();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment