initialize admin panel and necessry pages
This commit is contained in:
@@ -30,6 +30,7 @@ public sealed class GreenHomeDbContext : DbContext
|
||||
public DbSet<Domain.DevicePost> DevicePosts => Set<Domain.DevicePost>();
|
||||
public DbSet<Domain.DevicePostImage> DevicePostImages => Set<Domain.DevicePostImage>();
|
||||
public DbSet<Domain.PowerOutageLog> PowerOutageLogs => Set<Domain.PowerOutageLog>();
|
||||
public DbSet<Domain.UsageCounter> UsageCounters => Set<Domain.UsageCounter>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
@@ -445,5 +446,17 @@ public sealed class GreenHomeDbContext : DbContext
|
||||
b.HasIndex(x => new { x.DeviceId, x.PersianYear, x.PersianMonth });
|
||||
b.HasIndex(x => x.EventType);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Domain.UsageCounter>(b =>
|
||||
{
|
||||
b.ToTable("UsageCounters");
|
||||
b.HasKey(x => x.Id);
|
||||
b.HasOne(x => x.User)
|
||||
.WithMany()
|
||||
.HasForeignKey(x => x.UserId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
b.HasIndex(x => new { x.UserId, x.Date }).IsUnique();
|
||||
b.HasIndex(x => x.Date);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user