diff --git a/Database/AppDbContext.cs b/Database/AppDbContext.cs new file mode 100644 index 0000000..1ddbc06 --- /dev/null +++ b/Database/AppDbContext.cs @@ -0,0 +1,21 @@ +using Microsoft.EntityFrameworkCore; +using SoroushAsadi.Models; + +namespace SoroushAsadi.Database; + +public class AppDbContext(DbContextOptions options) : DbContext(options) +{ + public DbSet ContentSections => Set(); + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity(e => + { + e.ToTable("sections"); + e.HasKey(x => x.Key); + e.Property(x => x.Key).HasColumnName("key"); + e.Property(x => x.DataJson).HasColumnName("data"); + e.Property(x => x.UpdatedAt).HasColumnName("updated_at"); + }); + } +} diff --git a/Program.cs b/Program.cs index 2eea0ae..cce72c3 100644 --- a/Program.cs +++ b/Program.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.EntityFrameworkCore; -using SoroushAsadi.Data; +using SoroushAsadi.Database; using SoroushAsadi.Services; var builder = WebApplication.CreateBuilder(args); diff --git a/Services/ContentService.cs b/Services/ContentService.cs index 73010ce..26a9c54 100644 --- a/Services/ContentService.cs +++ b/Services/ContentService.cs @@ -1,6 +1,6 @@ using System.Text.Json; using System.Text.Json.Nodes; -using SoroushAsadi.Data; +using SoroushAsadi.Database; namespace SoroushAsadi.Services;