34 lines
1.2 KiB
C#
34 lines
1.2 KiB
C#
using Brizco.Domain.Entities.User;
|
|
using Brizco.Repository.Extensions;
|
|
|
|
namespace Brizco.Repository.Models;
|
|
|
|
public class ApplicationContext : IdentityDbContext<ApplicationUser,ApplicationRole,Guid>
|
|
{
|
|
private readonly ILogger<ApplicationContext> _logger;
|
|
private readonly Assembly _projectAssembly;
|
|
|
|
public ApplicationContext( DbContextOptions<ApplicationContext> options, ILogger<ApplicationContext> logger): base(options)
|
|
{
|
|
_logger = logger;
|
|
_projectAssembly = options.GetExtension<DbContextOptionCustomExtensions>().ProjectAssembly;
|
|
}
|
|
|
|
|
|
protected override void OnModelCreating(ModelBuilder builder)
|
|
{
|
|
var stopwatch = new Stopwatch();
|
|
stopwatch.Start();
|
|
base.OnModelCreating(builder);
|
|
var entitiesAssembly = _projectAssembly;
|
|
builder.RegisterAllEntities<ApiEntity>(_logger, entitiesAssembly);
|
|
stopwatch.Stop();
|
|
_logger.LogInformation($"!!!!!!! RegisterAllEntities : {stopwatch.ElapsedMilliseconds}ms !!!!!!!");
|
|
|
|
|
|
builder.RegisterEntityTypeConfiguration(entitiesAssembly);
|
|
builder.AddPluralizingTableNameConvention();
|
|
builder.AddRestrictDeleteBehaviorConvention();
|
|
//builder.AddSequentialGuidForIdConvention();
|
|
}
|
|
} |