ここに私のクラスのプロパティがあります:
public int ProductId { get; set; }
public string Name { get; set; }
public DateTime Creation { get; set; }
public int BrandId { get; set; }
public virtual Brand Brand { get; set; }
public int CreatedBy { get; set; }
public decimal Price { get; set;
public string Description { get; set; }
public string Properties { get; set; }
public bool OnFrontPage { get; set; }
public int StockCount { get; set; }
public decimal MarketPrice { get; set; }
public int CurrencyId { get; set; }
public virtual Currency Currency { get; set; }
public int TaxRate { get; set; }
public bool IsNewProduct { get; set; }
public bool IsActive { get; set; }
public string MetaDescription { get; set; }
public string MetaKeyWord { get; set; }
public int UnitId { get; set; }
public virtual Unit Unit { get; set; }
public int PointValue { get; set; }
public string RelatedProductIds { get; set; }
public int MaxSaleCount { get; set; }
public int ProductGroupId { get; set; }
public virtual ProductGroup ProductGroup { get; set; }
public virtual List<ProductCategory> ProductCategories { get; set; }
public virtual List<ProductType> ProductTypes { get; set; }
public virtual List<ProductImage> ProductImages { get; set; }
public virtual List<Promotion> Promotions { get; set; }
public int SaleCount { get; set; }
public virtual List<ProductChance> ProductChances { get; set; }
public string ProductCode { get; set; }
これは、コンテキストによって作成されたSQLクエリです。[Category_CategoryId] 列を追加するコンテキストですが、クラスまたはデータベーステーブルにカテゴリについて何もありません
SELECT
[Extent1].[ProductId] AS [ProductId],
[Extent1].[Name] AS [Name],
[Extent1].[Creation] AS [Creation],
[Extent1].[BrandId] AS [BrandId],
[Extent1].[CreatedBy] AS [CreatedBy],
[Extent1].[Price] AS [Price],
[Extent1].[Description] AS [Description],
[Extent1].[Properties] AS [Properties],
[Extent1].[OnFrontPage] AS [OnFrontPage],
[Extent1].[StockCount] AS [StockCount],
[Extent1].[MarketPrice] AS [MarketPrice],
[Extent1].[CurrencyId] AS [CurrencyId],
[Extent1].[TaxRate] AS [TaxRate],
[Extent1].[IsNewProduct] AS [IsNewProduct],
[Extent1].[IsActive] AS [IsActive],
[Extent1].[MetaDescription] AS [MetaDescription],
[Extent1].[MetaKeyWord] AS [MetaKeyWord],
[Extent1].[UnitId] AS [UnitId],
[Extent1].[PointValue] AS [PointValue],
[Extent1].[RelatedProductIds] AS [RelatedProductIds],
[Extent1].[MaxSaleCount] AS [MaxSaleCount],
[Extent1].[ProductGroupId] AS [ProductGroupId],
[Extent1].[SaleCount] AS [SaleCount],
[Extent1].[ProductCode] AS [ProductCode],
[Extent1].[Category_CategoryId] AS [Category_CategoryId]
FROM [dbo].[Product] AS [Extent1]}
カテゴリー:
public int CategoryId { get; set; }
public string Name { get; set; }
public string LinkText { get; set; }
public int? ParentId { get; set; }
public string Description { get; set; }
public string ImageUrl { get; set; }
public bool IsActive { get; set; }
public virtual List<Product> Products { get; set; }
public DateTime Creation { get; set; }
public int CreatedBy { get; set; }
public bool IsParentCategory { get; set; }