Files
petwash/PetWash.Api/Data/PetWashDbContext.cs

25 lines
919 B
C#
Raw Normal View History

2026-02-25 15:41:00 +08:00
using Microsoft.EntityFrameworkCore;
using PetWash.Api.Models;
namespace PetWash.Api.Data;
public class PetWashDbContext : DbContext
{
public PetWashDbContext(DbContextOptions<PetWashDbContext> options) : base(options) { }
public DbSet<Package> Packages { get; set; }
public DbSet<Order> Orders { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
// 初始化套餐数据
modelBuilder.Entity<Package>().HasData(
2026-02-26 14:30:48 +08:00
new Package { Id = 1, Name = "套餐1", Price = 50, DurationMinutes = 38, Description = "适用于小型犬" },
new Package { Id = 2, Name = "套餐2", Price = 80, DurationMinutes = 48, Description = "适用于中型犬" },
new Package { Id = 3, Name = "套餐3", Price = 120, DurationMinutes = 60, Description = "适用于大型犬" }
2026-02-25 15:41:00 +08:00
);
}
}