The application’s persistence layer is built on a SQL Server database namedDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/aws-samples/legacy-cycle-store-mvc-app/llms.txt
Use this file to discover all available pages before exploring further.
CYCLE_STORE. All product data lives under the Production schema in three related tables: Product, ProductCategory, and ProductSubcategory. Entity Framework 5 (Database-First, EDMX) maps these tables to C# entity classes that are auto-generated by T4 templates and consumed throughout the AdventureWorks.Business namespace.
Database Overview
TheCYCLE_STORE database organises its product catalogue into a three-level hierarchy. Categories group broad families of products (e.g., Bikes, Accessories). Each category owns one or more subcategories (e.g., Mountain Bikes, Road Bikes). Individual products belong to a subcategory via a nullable foreign key, allowing products that have not yet been fully classified to exist without breaking referential integrity.
ProductCategory
Top-level grouping. Each row has a unique name and owns a collection of subcategories.
ProductSubcategory
Mid-level grouping. Each row belongs to exactly one category and owns a collection of products.
Product
Leaf-level item. Contains all pricing, physical, and lifecycle attributes for a single SKU.
Production.Product
SQL Schema
C# Entity Class
Key Field Reference
| Field | Type | Notes |
|---|---|---|
ProductID | int | Primary key — uniquely identifies each SKU. |
ProductSubcategoryID | int? | Nullable FK to ProductSubcategory. A null value means the product has not been assigned to a subcategory. |
MakeFlag | bool | true = manufactured in-house; false = purchased from a vendor. |
FinishedGoodsFlag | bool | true = sellable finished good; false = component or sub-assembly not sold directly. |
ListPrice | decimal | The customer-facing price. A value of 0.00 indicates the product is not sold individually. |
StandardCost | decimal | Internal manufacturing or procurement cost used for margin calculations. |
Color | string | Nullable. Used by ProductManager.GetProductColor to build filter lists. |
Size | string | Nullable. Stores values like "S", "M", "L", "58" (frame size in cm). |
Weight | decimal? | Nullable. Stored in the unit identified by WeightUnitMeasureCode (e.g., "LB" or "G"). |
SellStartDate | DateTime | The date the product became available for sale — always populated. |
SellEndDate | DateTime? | Nullable. Populated when a product is retired from active sale. |
DiscontinuedDate | DateTime? | Nullable. Marks permanent discontinuation, distinct from end-of-sale. |
Production.ProductCategory
SQL Schema
C# Entity Class
ProductSubcategories to an empty HashSet<ProductSubcategory> so that navigation-property access never returns null, even before EF lazy-loads the collection. The virtual modifier enables EF’s proxy-based lazy loading.
Production.ProductSubcategory
SQL Schema
C# Entity Class
ProductCategoryID is the non-nullable FK column. The virtual ProductCategory navigation property allows EF to lazy-load the parent category from a subcategory instance without an explicit join in calling code.
Entity Relationships
The three entities form a strict parent-child-grandchild hierarchy:- ProductCategory → ProductSubcategory: One-to-many. A category has many subcategories; each subcategory belongs to exactly one category (
ProductCategoryID NOT NULL). - ProductSubcategory → Product: One-to-many. A subcategory has many products; a product optionally belongs to one subcategory (
ProductSubcategoryID NULL).
ProductCategory.ProductSubcategories for the first link, and the ProductSubcategory navigation on Product (materialised by the EDMX, accessed in LINQ joins within ProductManager).
CYCLE_STOREEntities DbContext
DbSet properties are the primary entry points for LINQ queries across the application:
| DbSet | Maps To |
|---|---|
Products | Production.Product |
ProductCategories | Production.ProductCategory |
ProductSubcategories | Production.ProductSubcategory |
"name=CYCLE_STOREEntities" is resolved from the <connectionStrings> section of Web.config at runtime.
Database-First with EDMX
CycleModel.edmx is a Database-First Entity Framework model. It was generated by pointing Visual Studio’s ADO.NET Entity Data Model Wizard at the live CYCLE_STORE SQL Server instance, which introspected the schema and produced the XML model file. The EDMX contains three sections — the Storage Model (SSDL, mirrors the SQL schema), the Conceptual Model (CSDL, the C# entities), and the Mappings (MSL, how columns map to properties).
The T4 template CycleModel.tt reads the CSDL section and emits a .cs file for each entity. CycleModel.Context.tt reads the same EDMX and emits CycleModel.Context.cs containing CYCLE_STOREEntities.
The OnModelCreating override deliberately throws UnintentionalCodeFirstException. This is EF’s safeguard: if something causes EF to treat the context as a Code-First context (e.g., an incorrect constructor call), the exception fires immediately rather than silently creating a wrong schema. In normal Database-First operation, OnModelCreating is never called because the model is loaded from the EDMX’s embedded metadata, not derived from the entity classes.
Product.cs, ProductCategory.cs, and ProductSubcategory.cs are auto-generated output from the T4 templates. Any manual edits made directly to these files will be silently overwritten the next time the EDMX is saved or the template is re-run. To add custom behaviour to an entity, create a separate partial class file in the same namespace — the partial keyword on each generated class exists precisely for this purpose.