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())
Book book = new Book(){Title = "My Book"};
var books = context.Books.ToList();
var booksInfo = context.Books
.SqlQuery("Select * from BooksInfo")
FiddleHelper.WriteTable(books);
FiddleHelper.WriteTable(booksInfo);
public class BookStore : DbContext
public BookStore() : base(FiddleHelper.GetConnectionStringSqlServer())
protected override void OnModelCreating(DbModelBuilder modelBuilder)
public DbSet<Book> Books { get; set; }
[Table("BooksInfo", Schema="library")]
public int BookId { get; set; }
public string Title { get; set; }