using System.Data.Common;
using System.Data.Entity;
using DatabaseEditor.DAL.Entities;
using MySql.Data.Entity;

namespace DatabaseEditor.DAL
{
[DbConfigurationType(typeof(MySqlEFConfiguration))]
public class LibraryDbContext : DbContext
{
    /// <summary>
    /// Constructor for initializing database.
    /// </summary>
    public LibraryDbContext(string connectionString, int authorsCount, int booksCount, int minAuthorsBooks, int maxAuthorsBooks)
        : base(connectionString)
    {
        Database.SetInitializer(new LibraryDbInitializer(authorsCount, booksCount, minAuthorsBooks, maxAuthorsBooks));
        Database.Initialize(false);
    }

    public LibraryDbContext(string connectionString)
        : base(connectionString)
    {
    }

    public LibraryDbContext(DbConnection existingConnection, bool contextOwnsConnection)
        : base(existingConnection, contextOwnsConnection)
    {
    }

    public virtual DbSet<Author> Authors { get; set; }
    public virtual DbSet<Book> Books { get; set; }
}
}