Używam "Entity Framework DbContext" w momencie, gdy mam wyjątek towars.dbo nie został znaleziony. Jest to bardzo dziwne, ponieważ na mojej stronie internetowej cały czas pytam o towar. Ale nie ma Towars.dbo Czy wiesz, gdzie jest problem?Entity Framework dodał s do mojego .dbo
- InnerException {"Invalid object name 'dbo.Towars'."} System.Exception {System.Data.SqlClient.SqlException}
My wszystko o towar (oczywiście inne miejsce w moim programie):
public class ProductController : Controller
{
//
// GET: /Product/
public ITowarRepository repository;
public ProductController(ITowarRepository productRepository)
{
repository = productRepository;
}
public ViewResult List()
{
return View(repository.Towar);
}
}
public interface ITowarRepository
{
IQueryable<Towar> Towar { get; }
}
public DbSet<Towar> Towar { get; set; }
public class EFTowarRepository : ITowarRepository
{
public EFDbContext context = new EFDbContext();
public IQueryable<Towar> Towar
{
get { return context.Towar; }
}
}
public class Towar
{
[Key]
public int Id_tow { get; set; }
public string Nazwa { get; set; }
public string Opis { get; set; }
public decimal Cena { get; set; }
public int Id_kat { get; set; }
}
jaka jest twoja nazwa tabeli w db? ARe jesteś podłączony do właściwego db? – Shyju
połączenie zrobić bazy danych jest poprawna connectionStrings> –
RPD