我正在使用实体框架编写带有 MVC4 和 VBNet 的应用程序。我有两个模型,Printer.vb 和 Request.vb
它们如下图所示,
请求.vb
Public Class Request
Public Property ID() As Integer
Public Property User() As String
Public Property Printer() As Printer
Public Property Approval() As Boolean
End Class
Public Class RequestDBContext
Inherits DbContext
Public Property Requests() As DbSet(Of Request)
End Class
打印机.vb
Public Class Printer
Public Property ID() As Integer
Public Property Name() As String
End Class
Public Class PrinterDBContext
Inherits DbContext
Public Property Printers() As DbSet(Of Printer)
End Class
我在创建引用数据库中存在的打印机模型的请求时遇到问题。
我的请求视图如下所示,
<div class="editor-field">
@Html.EditorFor(Function(model) model.User)
@Html.EditorFor(Function(model) model.Approval)
@Html.EditorFor(Function(model) model.Printer)
@Html.ValidationMessageFor(Function(model) model.User)
</div>
但是 `Model.EditorFor(model.Printer) 不会创建任何东西。
如何将字段添加到将找到打印机并在该请求中引用它的请求视图?