Witam. Postanowiłem napisać zwykłego CRUDa w ASP .Net core i natrafiłem na problem(chyba z relacją miedzy tabelami i nie wiem jak go naprawić). Oto błąd:
SqlException: Invalid column name 'ID_C'.
Invalid column name 'ID_P'.
Invalid column name 'ID_T'.
Invalid column name 'release_date'.
Tabele:
[Table("Books")]
public class BooksModel
{
[Key]
public int ID { get; set; }
[DisplayName("Tytuł")]
public string title { get; set; }
[DisplayName("Autor")]
public string author { get; set; }
[DisplayName("Data wydania")]
public DateTime release_date { get; set; }
[DisplayName("Wydawnictwo")]
[ForeignKey("ID_P")]
public virtual PublishingHausesModel publishing_hause { get; set; }
[DisplayName("Cena")]
public double price { get; set; }
[DisplayName("Liczba stron")]
public int number_of_pages { get; set; }
[DisplayName("Okladka")]
[ForeignKey("ID_C")]
public virtual CoversModel cover { get; set; }
[DisplayName("Opis")]
public string description { get; set; }
public bool bestseller { get; set; }
[DisplayName("Gatunek")]
[ForeignKey("ID_T")]
public virtual TypesModel type { get; set; }
[Table("Types")]
public class TypesModel
{
[Key]
public int ID_T { get; set; }
public string type { get; set; }
public virtual BooksModel Books { get; set; }
}
[Table("PublishingHauses")]
public class PublishingHausesModel
{
[Key]
public int ID_P { get; set; }
public string hause { get; set; }
public string adres { get; set; }
public virtual BooksModel Books { get; set; }
}
Na początku wywołuje się metoda która ma zwracać wszystkie książki:
public IQueryable<BooksModel> GetAllBooks()
{
var books = from f in _context.books select f;
return books;
}
Mógłby mnie ktoś nakierować co zrobiłem źle?