zhaw-dnet2/Tasks/Lab9/EntityFramework/EFCore/BloggingContext.cs

38 lines
1.1 KiB
C#

using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EFCore
{
public class BloggingContext : DbContext
{
DbSet<MealType> MealTypes { get; set; }
public DbSet<Meal> Meals { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);
optionsBuilder.UseSqlServer(@"Server=(local);initial catalog=FlughafenDB;integrated security=true;Trusted_Connection=True;TrustServerCertificate=True");
}
}
public class MealType
{
public int MealTypeId { get; set; }
public string? Description { get; set; }
public List<Meal> Meals { get; } = new();
}
public class Meal
{
public int MealId { get; set; }
public string? MealName { get; set; }
public string? MealDescription { get; set; }
public int MealTypeId { get; set; }
public MealType? MealType { get; set; }
}
}