Я получаю ошибку «недопустимое имя объекта" dbo.customers1»на мой взгляд ...Неверное имя объекта «dbo.customers1»
@foreach (var item in Model)
{
<tr>
<td>@item.orderid</td>
<td>@item.customer.firstname</td>
У меня есть классы ViewModel ...
public class orders
{
[Key]
public int orderid { get; set; }
public System.DateTime createdate { get; set; }
public string createdby { get; set; }
public Nullable<int> statusid { get; set; }
public Nullable<System.DateTime> pickup { get; set; }
public Nullable<System.DateTime> dropoff { get; set; }
public Nullable<System.DateTime> scheduledout { get; set; }
public Nullable<System.DateTime> scheduledin { get; set; }
public bool instorepickup { get; set; }
public string paymenttype { get; set; }
public System.DateTime reservationstart { get; set; }
public System.DateTime reservationend { get; set; }
public bool morningpickup { get; set; }
public Nullable<int> customerid { get; set; }
public string notes { get; set; }
public string shippingtype { get; set; }
public Nullable<decimal> shippingestimate { get; set; }
public virtual customer customer { get; set; }
public virtual ICollection<invoice> invoices { get; set; }
public virtual orderstatuses orderstatuses { get; set; }
public virtual ICollection<serialorders> serialorders { get; set; }
}
и
public class customers
{
[Key]
public int customerid { get; set; }
public System.DateTime createdate { get; set; }
public string firstname { get; set; }
public string lastname { get; set; }
[Required]
public string billingaddress1 { get; set; }
public string billingaddress2 { get; set; }
[Required]
public string billingcity { get; set; }
public string billingstate { get; set; }
[Required]
public string billingzip { get; set; }
[Required]
public string billingcountry { get; set; }
public string phone { get; set; }
[Required]
public string email { get; set; }
[Required]
public string shippingaddress1 { get; set; }
public string shippingaddress2 { get; set; }
[Required]
public string shippingcity { get; set; }
public string shippingstate { get; set; }
[Required]
public string shippingzip { get; set; }
[Required]
public string shippingcountry { get; set; }
public bool goodstanding { get; set; }
public string userid { get; set; }
public Nullable<DateTime> insuranceexp { get; set; }
public virtual ICollection<invoice> invoices { get; set; }
public virtual ICollection<order> orders { get; set; }
}
это моя модель ...
И у меня есть слой доступа к данным ...
public DbSet<tvc.viewModels.orders> orders { get; set; }
public DbSet<tvc.viewModels.customers> customers { get; set; }
Его база данных сначала и модель синхронизированы с db. Я не знаю, почему он ищет клиентов1. Я предполагаю, что это связано с соглашениями, а mvc добавляет 1? Я думаю, что у меня неверно установлены отношения в db или в viewmodel, но я показал все в своем вопросе ... – tintyethan
Добро пожаловать в радости EDMX. Для чего это стоит, вы можете использовать Code First с существующей базой данных, которая на самом деле является предпочтительной на данный момент, поскольку EDMX устарел (см. Http://cpratt.co/entity-framework-code-first-with-existing- база данных/). Если вы хотите придерживаться EDMX, я бы рекомендовал просто восстановить его из вашей базы данных. Это должно исправить любую проблему. –
хорошая информация - спасибо – tintyethan