Created
August 2, 2019 08:54
-
-
Save ngohungphuc/2651d80f38ea5d24663195ed43bcd163 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Post | |
{ | |
public int UserId { get; set; } | |
[DatabaseGenerated(DatabaseGeneratedOption.None)] | |
public int Id { get; set; } | |
public string Title { get; set; } | |
public string Body { get; set; } | |
public ICollection<Comment> Comments { get; set; } | |
} | |
public class Comment | |
{ | |
[ForeignKey("PostId")] | |
public Post Post { get; set; } | |
public int PostId { get; set; } | |
[DatabaseGenerated(DatabaseGeneratedOption.None)] | |
public int Id { get; set; } | |
public string Name { get; set; } | |
public string Email { get; set; } | |
public string Body { get; set; } | |
} | |
public class AppDbContext : DbContext | |
{ | |
public AppDbContext(DbContextOptions<AppDbContext> options) | |
: base(options) | |
{ | |
} | |
public DbSet<Comment> Comments { get; set; } | |
public DbSet<Post> Posts { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment