[Solved] Data binding directly to a store query (DbSet DbQuery DbSqlQuery) is not supported.

Last Reply one year ago By Mudassar

Posted one year ago


I am getting the following error when binding Entity Framework data to DataGridView.

An unhandled exception of type 'System.NotSupportedException' occurred in EntityFramework.dll

Additional information: 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().


private void Form1_Load(object sender, EventArgs e)
    NorthwindEntities entities = new NorthwindEntities();
    var customers = from p in entities.Customers
                    select new
                        CustomerId = p.CustomerID,
                        ContactName = p.ContactName,
                        Country = p.Country
    dataGridView1.DataSource = customers;

You are viewing reply posted by: Mudassar one year ago.
Posted one year ago

Simply add ToList() to your variable

dataGridView1.DataSource = customers.ToList();