Files
administration/Models/HelloFresh/HelloFreshContext.cs
2025-09-03 20:17:50 +02:00

93 lines
3.9 KiB
C#

using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
namespace administration.Models.HelloFresh;
public partial class HelloFreshContext : DbContext
{
public HelloFreshContext()
{
}
public HelloFreshContext(DbContextOptions<HelloFreshContext> options)
: base(options)
{
}
public virtual DbSet<HistoriqueRecette> HistoriqueRecettes { get; set; }
public virtual DbSet<Ingredient> Ingredients { get; set; }
public virtual DbSet<Recette> Recettes { get; set; }
public virtual DbSet<SavingRecette> SavingRecettes { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263.
=> optionsBuilder.UseSqlServer("Server=217.154.116.43;Database=HelloFresh;User Id=sa;Password=Mf33ksTRLrPKSqQ4cTXitgiSN6BPBt89;TrustServerCertificate=True;");
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<HistoriqueRecette>(entity =>
{
entity.Property(e => e.Id).HasColumnName("id");
// Map DateOnly -> date SQL
entity.Property(e => e.DateHistorique)
.HasConversion(
v => v.ToDateTime(TimeOnly.MinValue), // vers SQL
v => DateOnly.FromDateTime(v) // depuis SQL
)
.HasColumnType("date");
entity.Property(e => e.RecetteId).HasColumnName("recetteId");
entity.Property(e => e.UserId).HasColumnName("userId");
});
modelBuilder.Entity<Ingredient>(entity =>
{
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.NameOwnedIngredients).HasColumnName("nameOwnedIngredients");
});
modelBuilder.Entity<Recette>(entity =>
{
entity.HasNoKey();
entity.Property(e => e.Description).HasColumnName("description");
entity.Property(e => e.Difficulte)
.HasMaxLength(50)
.HasColumnName("difficulte");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Image).HasColumnName("image");
entity.Property(e => e.Ingredients).HasColumnName("ingredients");
entity.Property(e => e.IngredientsToHad).HasColumnName("ingredientsToHad");
entity.Property(e => e.Kcal)
.HasMaxLength(10)
.IsFixedLength()
.HasColumnName("kcal");
entity.Property(e => e.Name).HasColumnName("name");
entity.Property(e => e.Pdf).HasColumnName("pdf");
entity.Property(e => e.Preference).HasColumnName("preference");
entity.Property(e => e.Proteines)
.HasMaxLength(10)
.IsFixedLength()
.HasColumnName("proteines");
entity.Property(e => e.Slug).HasColumnName("slug");
entity.Property(e => e.SupplementText).HasColumnName("supplementText");
entity.Property(e => e.Tags).HasColumnName("tags");
entity.Property(e => e.TempsDePreparation).HasColumnName("tempsDePreparation");
});
modelBuilder.Entity<SavingRecette>(entity =>
{
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.IdSavingRecette).HasColumnName("idSavingRecette");
entity.Property(e => e.UserId).HasColumnName("userId");
});
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}