Test Entity Framework
This commit is contained in:
37
USEntryCoach.Server/Data/TestModel.cs
Normal file
37
USEntryCoach.Server/Data/TestModel.cs
Normal 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; }
|
||||
}
|
||||
Reference in New Issue
Block a user