I'm taking an ASP.NET course and I've been trying to rework an example in my textbook and while I've been able to get it to work with the included examples I can't figure out why it won't work in my own project. I believe the primary difference is the location of the database, the book example includes a local .mdf file whereas my project is using an offsite server.
protected void Page_Load(object sender, EventArgs e) {
using (FakeMartEntities fakeMartProducts = new FakeMartEntities()) {
var fakeProducts = from fProducts in fakeMartProducts.tProducts
orderby fProducts.Description ascending
select fProducts;
ddlProducts.DataSource = fakeProducts;
ddlProducts.DataBind();
}
}
I receive the following error:
Data binding directly to a store query (DbSet, DbQuery, DbSqlQuery) is not supported. Instead populate a DbSet with data, for example by calling Load on the DbSet, and then bind to local data. For WPF bind to DbSet.Local. For WinForms bind to DbSet.Local.ToBindingList().
I've done a few searches on this but none of the answers seem to take the same approach as my book and I'm perplexed as to why the book example does not throw this error. Also, the book recommends deleting the .tt files that are generated whenever adding an ADO.NET Entity Model.