[ビューの追加]ダイアログでビューを生成するときに、EntityFrameworkの外部キーを取得するにはどうすればよいですか。
私のモデルは
public class System
{
#region Properties
public int SystemId { get; set; }
public string SystemName { get; set; }
#endregion
}
public class Module
{
#region Properties
public int ModuleId { get; set; }
//[Required]
[Display(Name="Module Name")]
public string ModuleName { get; set; }
[Display(Name="Date Added")]
public DateTime DateAdded { get; set; }
//[ForeignKey("CurrentSystem")]
public int SystemId { get; set; }
//[ForeignKey()]
//[ForeignKey("SystemId")]
public System System { get; set; }
#endregion
}
コントローラをクリックしてからビューを追加をクリックすると、モーダルが開きます。必要なすべての詳細を選択すると、以下が生成されます(ビュー全体を含めませんでした)。
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>Module</legend>
<div class="editor-label">
@Html.LabelFor(model => model.ModuleName)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.ModuleName)
@Html.ValidationMessageFor(model => model.ModuleName)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.DateAdded)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.DateAdded)
@Html.ValidationMessageFor(model => model.DateAdded)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.SystemId)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.SystemId)
@Html.ValidationMessageFor(model => model.SystemId)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
SystemIdをテキストフィールドではなくドロップダウンにしたい。どうすればこれを行うことができますか?