Amastaneh blog is a discussion site on software development, programming, algorithms, software architectures,software run-time errors and solutions from software engineers who love building great softwares.
February 05, 2013
Data binding ... not supported
Exception:
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
Cause:
- 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();
xyz.Table.ToList();
this.gridControl1.ItemsSource = xyz.Table1.Local;
References:
- http://stackoverflow.com/questions/8263405/how-to-convert-a-dbset-to-an-observablecollection-in-wpf
- http://msdn.microsoft.com/en-us/data/jj574514.aspx
- http://stackoverflow.com/questions/4843391/entity-framework-code-first-dbset-local-not-updating-in-ui
Subscribe to:
Post Comments (Atom)
1 comment:
THANK YOU!!!!!!!!!!!!!!!!!!!!!!!! IT NOW WORKS!! took me hours and hours to try and figure this out
Post a Comment