Müşteri bilgilerini görüntülemek istiyorum. Sonra bazı sınıflar oluşturdum; Müşteri, Teslimat, Sipariş, Sipariş Hattı, Ürün ve kiralamaDB. kiralamaDB class setleri 5 DbSet Ürün, Müşteri, Sipariş, Sipariş Hattı ve Teslimat. Listenin görüntüsü UserController yaptığınızda , ben müşteri bilgilerini gösteremez ve bu hataları alır: bu varlıkların anahtarı gerektiren nedenASP.NET MVC 3 EntityType tanımlanmış hiçbir anahtar yok
One or more validation errors were detected during model generation:
System.Data.Edm.EdmEntityType: : EntityType 'OrderLine' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'Delivery' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �OrderLine� is based on type �OrderLine� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �Delivery� is based on type �Delivery� that has no keys defined.
Bilmiyorum? Bu hata hakkında hiçbir fikrim yok .. Yardımcı olabilir misiniz? Modeller
namespace MvcApplication2.Models
{
public class OrderLine
{
public int basketId { get; set; }
public int productId { get; set; }
public int quantity { get; set; }
}
}
folder-- modeller
namespace MvcApplication2.Models
{
public class Delivery
{
public int trackId { get; set; }
public String address { get; set; }
public String postCode { get; set; }
public decimal deliveryPrice { get; set; }
public DateTime deliveryDate { get; set; }
public DateTime returnDate { get; set; }
}
}
--OrderLine.cs folder-- içinde
--UserController.cs--
namespace MvcApplication2.Controllers
{
public class UserController : Controller
{
//
// GET: /User/
rentalDB _db = new rentalDB();
public ActionResult Index()
{
var model = _db.Customer;
return View(model);
}
}
}
--Delivery.cs
Bu benim için özel bir durumda çalıştı. Modelin kodunu yazdıktan sonra bir denetleyici ekledim ve hatayı almadım. Bu noktada, modelin istediğim gibi olmadığını, oluşturulan tüm görüntülerin çok yanlış olduğunu anladım, böylece denetleyiciyi/görünümleri sildim. Sonra modeli tamir ettiğimde ve kontrol cihazını eklediğimde hata ortaya çıktı. Bir saat uğraştıktan sonra [Key] ekledim ve işe yaradı. Belki görsel stüdyo Mvc tuhaflık veya önbellek, bilmiyorum ... – isitdanny