Lots of data and model setup
This commit is contained in:
@@ -26,7 +26,7 @@ public class DCGEDbContext : DbContext
|
||||
{
|
||||
if (entityEntry.Entity is ITimeTrackedEntity timeTrackedEntity)
|
||||
{
|
||||
if (entityEntry.State is EntityState.Added && timeTrackedEntity.DateCreated is null)
|
||||
if (entityEntry.State is EntityState.Added && timeTrackedEntity.DateCreated == DateTime.MinValue)
|
||||
{
|
||||
timeTrackedEntity.DateCreated = DateTime.UtcNow;
|
||||
}
|
||||
@@ -49,7 +49,15 @@ public class DCGEDbContext : DbContext
|
||||
{
|
||||
modelBuilder.Entity(typeInfo.AsType());
|
||||
}
|
||||
foreach (var typeInfo in assembly.DefinedTypes.Where(type => type.IsAssignableTo(typeof(IDataSeeder))))
|
||||
{
|
||||
((IDataSeeder?)Activator.CreateInstance(typeInfo.AsType()))?.Seed(modelBuilder);
|
||||
}
|
||||
});
|
||||
|
||||
modelBuilder.Entity<DeckEntry>()
|
||||
.OwnsMany<DeckCard>(de => de.Cards);
|
||||
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user