using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.SqlServer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WebApiExample2.Data.Model;

namespace WebApiExample2.Data.Context
{
    /*
     * 
     * The LibraryContext class inherits from the 
     * DbContext which is the main class of 
     * Microsoft's ORM called Entity Framework
     * It performs the mapping of classes to database tables 
     * and vice versa
     * 
     */
     
    public class LibraryContext : DbContext
    {
        //The Books property corresponds to
        //the Books table in the database
        public DbSet<Book> Books { get; set; }
    
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            //Database connection string
            optionsBuilder.UseSqlServer(
                "Data Source=(LocalDb)\\MSSQLLocalDB;Initial Catalog=Library;Integrated Security=True");
        }
    }
}
