我在房屋和租户之间有多对多的关系。我有点困惑如何全部解决,调试器说我的列名是
Tenants_TenantID 但不是,它的 TenantID ?
我的错误
{"无效的列名 'Tenants_TenantID'。\r\n无效的列名 'House_HouseID'。"}
我的错误来自哪里
@using (Html.BeginForm("AddRole", "Role", new { houseId = @Model.HouseID }))
{
<table>
<tr>
<td>Select to Add Item</td>
<td>
<div class="editor-field">
@Html.ListBoxFor(model => model.TenantID, ((IEnumerable<FlatSystem.Models.Tenants>)ViewBag.TenantLookupList).Select(option => new SelectListItem
{
Text = Html.DisplayTextFor(_ => option).ToString(),
Value = option.TenantID.ToString(),
Selected = (Model != null)
}), "Choose...")
</div>
</td>
<td><input type="submit" value="Add" /></td>
</tr>
</table>
}
固定的
我通过更新我的 DBContext 文件解决了这个问题。
我犯了一个简单的错误,错过了我的多对多关系的第三张表的 DbSet