public void Configure(EntityTypeBuilder <Category> builder)
        {
            builder.HasKey(c => c.CategoryId);

            builder.Property(c => c.Name)
            .HasMaxLength(100)
            .IsRequired();

            builder.HasData(ProductsContextExtensionSeed.SeedData <Category>("Categories.json"));
        }
        public void Configure(EntityTypeBuilder <ProductCategory> builder)
        {
            builder.HasKey(pc => pc.ProductCategoryId);

            builder.HasOne(pc => pc.Category)
            .WithMany(c => c.ProductCategories)
            .HasForeignKey(pc => pc.CategoryId);

            builder.HasOne(pc => pc.Product)
            .WithMany(p => p.ProductCategories)
            .HasForeignKey(pc => pc.ProductId);

            builder.HasData(ProductsContextExtensionSeed.SeedData <ProductCategory>("ProductCategories.json"));
        }
Exemple #3
0
        public void Configure(EntityTypeBuilder <Product> builder)
        {
            builder.HasKey(p => p.ProductId);

            builder.Property(p => p.Name)
            .HasMaxLength(100)
            .IsRequired();

            builder.Property(p => p.Price)
            .HasDefaultValue(0)
            .IsRequired();

            builder.HasOne(p => p.Supplier)
            .WithMany(s => s.Products)
            .HasForeignKey(p => p.SupplierId);

            builder.HasData(ProductsContextExtensionSeed.SeedData <Product>("Products.json"));
        }
Exemple #4
0
        public void Configure(EntityTypeBuilder <Supplier> builder)
        {
            builder.HasKey(s => s.SupplierId);

            builder.Property(s => s.SupplierName)
            .HasMaxLength(100)
            .IsRequired();

            builder.Property(s => s.Country)
            .HasMaxLength(100)
            .IsRequired();

            builder.Property(s => s.City)
            .HasMaxLength(100)
            .IsRequired();

            builder.HasData(ProductsContextExtensionSeed.SeedData <Supplier>("Suppliers.json"));
        }