Notes
This commit is contained in:
parent
4c2b5cca93
commit
43b4d50e43
28 changed files with 674 additions and 249 deletions
|
|
@ -1,22 +1,19 @@
|
|||
using InkForge.Data.Infrastructure;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace InkForge.Data;
|
||||
|
||||
public class NoteDbContext(
|
||||
DbContextOptions<NoteDbContext> options
|
||||
DbContextOptions options
|
||||
) : DbContext(options)
|
||||
{
|
||||
public DbSet<Blob> Blobs { get; set; } = default!;
|
||||
|
||||
public DbSet<MetadataEntity> Metadata { get; set; } = default!;
|
||||
|
||||
public DbSet<MetadataVersionEntity> MetadataHistory { get; set; } = default!;
|
||||
|
||||
public DbSet<NoteEntity> Notes { get; set; } = default!;
|
||||
|
||||
public DbSet<NoteVersionEntity> NoteVersions { get; set; } = default!;
|
||||
public NoteDbContext(DbContextOptions<NoteDbContext> options) : this((DbContextOptions)options)
|
||||
{ }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
|
|
@ -25,26 +22,13 @@ public class NoteDbContext(
|
|||
options.HasKey(m => m.Id);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<MetadataVersionEntity>(options =>
|
||||
{
|
||||
options.Property(m => m.Id).IsRequired();
|
||||
options.HasKey(m => m.Version);
|
||||
options.HasIndex(nameof(MetadataVersionEntity.Id), nameof(MetadataVersionEntity.Version)).IsUnique();
|
||||
});
|
||||
|
||||
modelBuilder.Entity<NoteEntity>(options =>
|
||||
{
|
||||
options.OwnsOne(m => m.Value);
|
||||
|
||||
options.HasKey(m => m.Id);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<NoteVersionEntity>(options =>
|
||||
{
|
||||
options.OwnsOne(m => m.Value);
|
||||
options.Property(m => m.Id).IsRequired();
|
||||
options.HasKey(m => m.Version);
|
||||
options.HasIndex(nameof(NoteVersionEntity.Id), nameof(NoteVersionEntity.Version)).IsUnique();
|
||||
|
||||
options.HasOne(m => m.Parent);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue