using Common.Model;
using Common.Util;
using Microsoft.EntityFrameworkCore;

namespace Common.Database
{
    public class ApiaryContext : DbContext
    {
        public DbSet<Product> Products { get; set; }
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseSqlite("Data Source=absolute/path/to/the/apiary.sqlite");
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Product>()
                .Property(p => p.Image)
                .HasConversion<ImageToBytesConverter>();
        }
    }
}
