using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
public static void Main()
using (var context = new BookStore())
Author author = new Author()
Biography = new AuthorBiography()
DateOfBirth = DateTime.Now,
context.Authors.Add(author);
var authorData = context.Authors.ToList();
var authorBio = context.AuthorBiographies.ToList();
FiddleHelper.WriteTable(authorData);
FiddleHelper.WriteTable(authorBio);
public class BookStore : DbContext
public BookStore() : base(FiddleHelper.GetConnectionStringSqlServer())
protected override void OnModelCreating(DbModelBuilder modelBuilder)
public DbSet<Author> Authors { get; set; }
public DbSet<AuthorBiography> AuthorBiographies { get; set; }
public class AuthorBiography
public int AuthorBiographyId { get; set; }
public string Biography { get; set; }
public DateTime DateOfBirth { get; set; }
public string PlaceOfBirth { get; set; }
public string Nationality { get; set; }
public virtual Author Author { get; set; }
public int AuthorId { get; set; }
public string Name { get; set; }
public virtual AuthorBiography Biography { get; set; }