I am using SQLite in my application and my table is defined as per this EF model:
internal class Board
{
public string BoardID { get; set; }
public ushort BoardNumber { get; set; }
public string Content { get; set; }
public Board()
{
BoardID = string.Empty;
Content = string.Empty;
BoardNumber = 0;
}
}
The property names match exactly the database columns. I am able to fetch records with the same model using LINQ to Entity. However, when I try this operation it fails with the error stated in the subject:
using (var db = new Models.EF.MyDbContext())
{
int last - db.Boards.Max(n => n.BoardNumber);
}
The column in the database is named "BoardNumber" and is of type integer (SQLite) and is NOT the PK.
Why is this operation failing?