Test Entity Framework

This commit is contained in:
Simon Lübeß
2025-05-27 14:17:47 +02:00
parent dffd31cd0f
commit 9e7ec186cd
8 changed files with 314 additions and 0 deletions

View File

@ -0,0 +1,37 @@
using Microsoft.EntityFrameworkCore;
namespace USEntryCoach.Server.Data;
public class BloggingContext : DbContext
{
public DbSet<Blog> Blogs { get; set; }
public DbSet<Post> Posts { get; set; }
public BloggingContext (DbContextOptions<BloggingContext> options)
: base(options)
{
}
//public string ConnectionString { get; } = configuration.GetConnectionString("Default") ?? "No connection string";
//protected override void OnConfiguring(DbContextOptionsBuilder options) => options.UseNpgsql(ConnectionString);
}
public class Blog
{
public int BlogId { get; set; }
public string Url { get; set; }
public List<Post> Posts { get; } = new();
}
public class Post
{
public int PostId { get; set; }
public string Title { get; set; }
public string Content { get; set; }
public int BlogId { get; set; }
public Blog Blog { get; set; }
}