Skip to content

Instantly share code, notes, and snippets.

@jeffhollan
Created May 29, 2019 04:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffhollan/5e9640e9f08e6d02c7c6933d385e77f2 to your computer and use it in GitHub Desktop.
Save jeffhollan/5e9640e9f08e6d02c7c6933d385e77f2 to your computer and use it in GitHub Desktop.
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Text;
namespace functions_csharp_entityframeworkcore
{
public class BloggingContext : DbContext
{
public BloggingContext(DbContextOptions<BloggingContext> options)
: base(options)
{ }
public DbSet<Blog> Blogs { get; set; }
public DbSet<Post> Posts { get; set; }
}
public class Blog
{
public int BlogId { get; set; }
public string Url { get; set; }
public ICollection<Post> Posts { get; set; }
}
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; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment