0% found this document useful (0 votes)
21 views12 pages

Auto

The document defines the data model and context for an e-commerce application using Entity Framework Core. It configures 8 entity types (Category, Member, Order, OrderDetail, Product) and their properties and relationships. Sample data is seeded for the Categories and Products tables. The ApplicationDBContext is set up to use this model and configuration.

Uploaded by

ducpmhe150400
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views12 pages

Auto

The document defines the data model and context for an e-commerce application using Entity Framework Core. It configures 8 entity types (Category, Member, Order, OrderDetail, Product) and their properties and relationships. Sample data is seeded for the Categories and Products tables. The ApplicationDBContext is set up to use this model and configuration.

Uploaded by

ducpmhe150400
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

// <auto-generated />

using System;

using BusinessObject;

using Microsoft.EntityFrameworkCore;

using Microsoft.EntityFrameworkCore.Infrastructure;

using Microsoft.EntityFrameworkCore.Metadata;

using Microsoft.EntityFrameworkCore.Storage.ValueConversion;

#nullable disable

namespace BusinessObject.Migrations

[DbContext(typeof(ApplicationDBContext))]

partial class ApplicationDBContextModelSnapshot : ModelSnapshot

protected override void BuildModel(ModelBuilder modelBuilder)

#pragma warning disable 612, 618

modelBuilder

.HasAnnotation("ProductVersion", "6.0.4")

.HasAnnotation("Relational:MaxIdentifierLength", 128);

SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);

modelBuilder.Entity("BusinessObject.Category", b =>
{

b.Property<int>("CategoryId")

.ValueGeneratedOnAdd()

.HasColumnType("int");

SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("CategoryId"));

b.Property<string>("CategoryName")

.IsRequired()

.HasMaxLength(40)

.HasColumnType("nvarchar(40)");

b.HasKey("CategoryId");

b.ToTable("Categories");

b.HasData(

new

CategoryId = 1,

CategoryName = "Beverages"

},

new

CategoryId = 2,
CategoryName = "Condiments"

},

new

CategoryId = 3,

CategoryName = "Confections"

},

new

CategoryId = 4,

CategoryName = "Dairy Products"

},

new

CategoryId = 5,

CategoryName = "Grains/Cereals"

},

new

CategoryId = 6,

CategoryName = "Meat/Poultry"

},

new

CategoryId = 7,
CategoryName = "Produce"

},

new

CategoryId = 8,

CategoryName = "Seafood"

});

});

modelBuilder.Entity("BusinessObject.Member", b =>

b.Property<int>("MemberId")

.ValueGeneratedOnAdd()

.HasColumnType("int");

SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("MemberId"));

b.Property<string>("City")

.IsRequired()

.HasColumnType("nvarchar(max)");

b.Property<string>("CompanyName")

.IsRequired()

.HasMaxLength(40)

.HasColumnType("nvarchar(40)");
b.Property<string>("Country")

.IsRequired()

.HasColumnType("nvarchar(max)");

b.Property<string>("Email")

.IsRequired()

.HasColumnType("nvarchar(max)");

b.Property<string>("Password")

.IsRequired()

.HasColumnType("nvarchar(max)");

b.HasKey("MemberId");

b.ToTable("Members");

});

modelBuilder.Entity("BusinessObject.Order", b =>

b.Property<int>("OrderId")

.ValueGeneratedOnAdd()

.HasColumnType("int");

SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("OrderId"));
b.Property<float>("Freight")

.HasColumnType("real");

b.Property<int>("MemberId")

.HasColumnType("int");

b.Property<DateTime?>("OrderDate")

.HasColumnType("datetime2");

b.Property<DateTime?>("RequiredDate")

.HasColumnType("datetime2");

b.Property<DateTime?>("ShippedDate")

.HasColumnType("datetime2");

b.HasKey("OrderId");

b.ToTable("Orders");

});

modelBuilder.Entity("BusinessObject.OrderDetail", b =>

b.Property<int>("OrderId")

.HasColumnType("int");
b.Property<string>("ProductId")

.HasColumnType("nvarchar(450)");

b.Property<float>("Discount")

.HasColumnType("real");

b.Property<int>("Quantity")

.HasColumnType("int");

b.Property<int>("UnitPrice")

.HasColumnType("int");

b.HasKey("OrderId", "ProductId");

b.ToTable("OrderDetails");

});

modelBuilder.Entity("BusinessObject.Product", b =>

b.Property<int>("ProductId")

.ValueGeneratedOnAdd()

.HasColumnType("int");

SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ProductId"));
b.Property<int>("CategoryId")

.HasColumnType("int");

b.Property<string>("ProductName")

.IsRequired()

.HasMaxLength(40)

.HasColumnType("nvarchar(40)");

b.Property<int>("UnitInStock")

.HasColumnType("int");

b.Property<int>("UnitPrice")

.HasColumnType("int");

b.Property<float>("Weight")

.HasColumnType("real");

b.HasKey("ProductId");

b.HasIndex("CategoryId");

b.ToTable("Products");

b.HasData(
new

ProductId = 1,

CategoryId = 1,

ProductName = "Coca Cola",

UnitInStock = 3,

UnitPrice = 10,

Weight = 1.1f

},

new

ProductId = 2,

CategoryId = 2,

ProductName = "Chin su",

UnitInStock = 2,

UnitPrice = 10,

Weight = 2.1f

},

new

ProductId = 3,

CategoryId = 3,

ProductName = "Sweet Candy",

UnitInStock = 1,

UnitPrice = 11,
Weight = 3.1f

},

new

ProductId = 4,

CategoryId = 4,

ProductName = "Nabati",

UnitInStock = 2,

UnitPrice = 10,

Weight = 4.1f

},

new

ProductId = 5,

CategoryId = 5,

ProductName = "Toki Cereal",

UnitInStock = 3,

UnitPrice = 11,

Weight = 5.1f

},

new

ProductId = 6,

CategoryId = 6,

ProductName = "Meatdeli",
UnitInStock = 1,

UnitPrice = 10,

Weight = 6.1f

},

new

ProductId = 7,

CategoryId = 7,

ProductName = "VN Rice Cake",

UnitInStock = 5,

UnitPrice = 10,

Weight = 7.1f

},

new

ProductId = 8,

CategoryId = 8,

ProductName = "Black Mamba Fish",

UnitInStock = 3,

UnitPrice = 11,

Weight = 8.1f

});

});

modelBuilder.Entity("BusinessObject.Product", b =>
{

b.HasOne("BusinessObject.Category", "Category")

.WithMany("Products")

.HasForeignKey("CategoryId")

.OnDelete(DeleteBehavior.Cascade)

.IsRequired();

b.Navigation("Category");

});

modelBuilder.Entity("BusinessObject.Category", b =>

b.Navigation("Products");

});

#pragma warning restore 612, 618

You might also like