Workspace Metadata Rows
This commit is contained in:
parent
e9c6e14965
commit
a62b5a1f29
8 changed files with 324 additions and 7 deletions
|
|
@ -9,14 +9,12 @@ namespace InkForge.Data
|
|||
|
||||
public abstract class Entity<TEntity, TKey>
|
||||
: ValueEntity<TEntity>
|
||||
where TKey : struct, INumber<TKey>
|
||||
{
|
||||
public TKey? Id { get; set; }
|
||||
}
|
||||
|
||||
public abstract class VersionedEntity<TEntity, TKey>
|
||||
: ValueEntity<TEntity>
|
||||
where TKey : struct, INumber<TKey>
|
||||
{
|
||||
public TKey Id { get; set; }
|
||||
|
||||
|
|
|
|||
5
shared/InkForge.Data/Infrastructure/MetadataEntities.cs
Normal file
5
shared/InkForge.Data/Infrastructure/MetadataEntities.cs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
namespace InkForge.Data.Infrastructure;
|
||||
|
||||
public class MetadataEntity : Entity<string, string>;
|
||||
|
||||
public class MetadataVersionEntity : VersionedEntity<string, string>;
|
||||
|
|
@ -10,12 +10,28 @@ public class NoteDbContext(
|
|||
{
|
||||
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!;
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<MetadataEntity>(options =>
|
||||
{
|
||||
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue