モデル:だからEntity Frameworkのコード6+まず複数のモデル
ManufacturersModel.cs
public class Manufacturers
{
[Key]
public int ManufacturerID { get; set; }
[Required]
[StringLength(100)]
public string Name { get; set; }
public int AddressID { get; set; }
public Address Address { get; set; }
[EmailAddress]
[StringLength(150)]
public string EmailAddress { get; set; }
[Phone]
[StringLength(20)]
public string PhoneNumber { get; set; }
public ICollection<Brands> Brands { get; set; }
}
BrandsModel.cs
public class Brands
{
[Key]
public int BrandID { get; set; }
[Required]
[StringLength(100)]
public string BrandName { get; set; }
[Required]
public int ManufacturerID { get; set; }
public Manufacturers Manufacturers { get; set; }
public ICollection<Products> Products { get; set; }
}
のために "作成" ページを作成しようとすると、ブランド、私は2つのフィールド:ブランド名とメーカー名が必要です。ブランド名は、ユーザーが望むものを入力するテキストボックス/エディタになります。依存関係のためにメーカー名が必要なのは、jQuery UIのオートコンプリートドロップダウンであるため、依存関係が満たされることがわかります。しかし、自分の@modelがBrandsかManufacturersかどうかはわかりません。
これは、複数のモデルが必要な可能性のある他のページにも及んでいます。私は、作成したすべてのモデルを含むコンテキストを持っていますが、ページにコンテキストを送信するか、モデルを送信する必要があるかどうかはわかりません。一例として、作成したい別のページは、[商品名] jQuery UIのオートコンプリートドロップダウンとブランド名jQuery UIのオートコンプリートドロップダウンがあります。ブランドはメーカーに関連しています。
ちょうどコードファーストの開発に入るので、私が得ることができるすべてのヘルプとヒントが必要です。どうもありがとうございます。