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())
var author = context.Authors
.Where(a => a.AuthorId == 2)
context.Authors.Remove(author);
var authors = context.Authors.ToList();
FiddleHelper.WriteTable(authors);
public static void InsertData()
using (var context = new BookStore())
Author author1 = new Author()
Author author2 = new Author()
Author author3 = new Author()
context.Authors.Add(author1);
context.Authors.Add(author2);
context.Authors.Add(author3);
public class BookStore : DbContext
public BookStore() : base(FiddleHelper.GetConnectionStringSqlServer())
public DbSet<Author> Authors { get; set; }
public int AuthorId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }