Get items stored and retrieved from the db

This commit is contained in:
TheXamlGuy
2024-05-12 14:50:10 +01:00
parent fd1c7e01be
commit c5c2756c5b
15 changed files with 84 additions and 90 deletions
+24
View File
@@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore;
namespace Bitvault.Data;
public class ContainerDbContext(DbContextOptions<ContainerDbContext> options) :
DbContext(options)
{
public DbSet<Document> Documents { get; set; }
public DbSet<Item> Items { get; set; }
public DbSet<Tag> Tags { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Item>()
.HasMany(x => x.Tags)
.WithOne();
modelBuilder.Entity<Item>()
.HasMany(x => x.Documents)
.WithOne();
}
}