Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using ProductService.Models;
- using Microsoft.EntityFrameworkCore;
- namespace ProductService.DBContext
- {
- public class ProductContext : DbContext, IProductContext
- {
- public ProductContext(DbContextOptions<ProductContext> options) : base(options)
- {
- }
- public DbSet<Product> Products { get; set; }
- public DbSet<Category> Categories { get; set; }
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- modelBuilder.Entity<Category>().HasData(
- new Category
- {
- Id = 1,
- Name = "Electronics",
- Description = "Electronic Items",
- },
- new Category
- {
- Id = 2,
- Name = "Clothes",
- Description = "Dresses",
- },
- new Category
- {
- Id = 3,
- Name = "Grocery",
- Description = "Grocery Items",
- }
- );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement