using Microsoft.EntityFrameworkCore; using GrossesMitainesAPI.Models; namespace GrossesMitainesAPI.Data; public class InventoryContext : DbContext { public DbSet Products { get; set; } public InventoryContext(DbContextOptions options) : base(options) { } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); // Pour partir la BD. modelBuilder.Entity().HasData(new Product { Id = 1, Title = $"", Description = $"", Price = 0.00M, ImageData = $"" }); } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json") .Build(); var connectionString = configuration.GetConnectionString("DefaultConnection"); optionsBuilder.UseSqlServer(connectionString); } }