Не отображается содержимое БД?
При выводе из базы данных всего содержимого выдает ошибку - Sequence contains more than one matching element Вывожу с помощью кода -
public IActionResult Products()
{
return View(db.Specifications.ToList());
}
И в папке Veiw с помощью данного кода -
<h2>Список пользователей</h2>
<p><a asp-action="CreateProducts">Добавить пользователя</a></p>
<table class="table">
<tr><th>Id</th><th>Название</th><th>Бренд</th></tr>
@foreach (var item in Model)
{
<tr>
<td>@item.Id</td>
<td>@item.Name</td>
<td>@item.Brand</td>
</tr>
}
</table>
Полный вывод ошибок -
An unhandled exception occurred while processing the request.
InvalidOperationException: Sequence contains more than one matching element
System.Linq.ThrowHelper.ThrowMoreThanOneMatchException()
TypeInitializationException: The type initializer for 'Microsoft.EntityFrameworkCore.Query.QueryableMethods' threw an exception.
Microsoft.EntityFrameworkCore.Query.QueryableMethods.get_FirstWithPredicate()
TypeInitializationException: The type initializer for 'Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor' threw an exception.
Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor.Expand(Expression query)
Вм последней ошибке TypeInitializationException: The type initializer for 'Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor' threw an exception. указываает на return View(db.Specifications.ToList());.
База данных не содержит одинаковых элементов и содержит только одну строку значений.Как исправить не знаю.Спасибо!