February 05, 2013

Data binding ... not supported

Message: 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().
Source: EntityFramework

- If you want to use of Visual Studio 2012 instead of 2010
- If your project used of .Net Framework 4.0 and below
- If you upgrade Entity Framework from EF4.0 to EF4.1 or EF5.0 (CTP 5.0)
- If you Upgrade ADO .NET Entity Data Model and generate it again ;-)
- If your Model used of DbSet/DbSet<T> Instead of ObjectSet ***
Ok, you in trouble like me ;-)

Problem Case:
This case is good in VS2010 with EF4.0 with Old Model which used of ObjectSet
XYZEntities xyz = new XYZEntities();
this.gridControl1.ItemsSource = xyz.Table1;

Solution Case:
- Upgrade your project to .Net 4.5
- Use of Local Property ;-)
XYZEntities xyz = new XYZEntities();
this.gridControl1.ItemsSource = xyz.Table1.Local;


1 comment:

Anonymous said...

THANK YOU!!!!!!!!!!!!!!!!!!!!!!!! IT NOW WORKS!! took me hours and hours to try and figure this out