Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Blog>().Property(x => x.Id).ValueGeneratedNever();
modelBuilder.Entity<Blog>().HasKey(x => x.Id);
modelBuilder.Entity<Blog>().HasMany(x=>x.Posts).WithOne().IsRequired();
modelBuilder.Entity<Blog>().Property(x => x.Name);
modelBuilder.Entity<Post>().Property(x => x.Id).ValueGeneratedNever();
modelBuilder.Entity<Post>().HasKey(x => x.Id);
modelBuilder.Entity<Post>().Property(x => x.Title);
modelBuilder.Entity<Post>().Property(x => x.Content);
base.OnModelCreating(modelBuilder);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.