43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace WebDoorCreator.Data
|
|
{
|
|
public class ApplicationDbContext : IdentityDbContext
|
|
{
|
|
public ApplicationDbContext()
|
|
{
|
|
try
|
|
{
|
|
// se non ci fosse... crea o migra!
|
|
Database.Migrate();
|
|
}
|
|
catch (Exception exc)
|
|
{ }
|
|
}
|
|
|
|
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
|
|
: base(options)
|
|
{
|
|
#if false
|
|
// se non ci fosse... crea!
|
|
Database.EnsureCreated();
|
|
#endif
|
|
try
|
|
{
|
|
// se non ci fosse... crea o migra!
|
|
Database.Migrate();
|
|
}
|
|
catch (Exception exc)
|
|
{ }
|
|
}
|
|
protected override void OnModelCreating(ModelBuilder builder)
|
|
{
|
|
base.OnModelCreating(builder);
|
|
|
|
builder.ApplyConfiguration(new RoleConfiguration());
|
|
builder.ApplyConfiguration(new UserConfiguration());
|
|
}
|
|
|
|
}
|
|
} |