Note that there are some explanatory texts on larger screens.

plurals
  1. POEF DataContext incompatible with datagrid use of EF? (VS11)
    text
    copied!<p>I have a VS11 beta WPF application with a Microsoft Datagrid based on a table from an Entity Framework 5.0b2 model (from an sql server database). (The grid uses whatever code was autogenerated by adding a data source from an entity framework model and dragging and dropping a table from that model to the design surface.). I then used the EF5.0 DBContext code generator add-in to generate DbContext types that I could use in the app. </p> <p>The result was not good. I got a compile error that seems unfixable; at least my attempts made things worse. The datagrid does not like DbContext and doesn't co-exist with it (when both the datagrid and DbContext are based on the same database and tables). Is there a workaround, maybe by changing the code generator template?</p> <p>The error message is pasted at the end. Thanks for any help or insight on this. </p> <p>(note the following closely related post isn't an answer because though I can convert dbcontext to objectcontext, I can't get datagrid to work properly with it when I do; and if I convert objectcontext to dbcontext, I don't have the autogenerated dbcontext types: <a href="https://stackoverflow.com/questions/8059900/convert-dbcontext-to-objectcontext-for-use-with-gridview">Convert DBContext to ObjectContext for use with GridView</a>). I'm looking for a fairly simple workaround--I'm sure there's a workaround if I start hand coding all types and conversions, but I want to keep the ease of using the autogenerated code--I don't want to be occupied with work the code generator can, and so should, do. If there isn't a solution, I suppose I'll base the controls on ado.net and leave entity framework for non-ui code. </p> <p>Error<br> Cannot implicitly convert type 'System.Data.Entity.DbSet' to 'System.Data.Objects.ObjectQuery'</p> <p>Documents\Visual Studio 11\Projects\WpfApplication3\WpfApplication3\MainWindow.xaml.cs</p> <p>The line that caused the error (created by Microsoft drag and drop of the datagrid with an EF table as the source): System.Data.Objects.ObjectQuery myTblsQuery = myDbsEntities.MyTbls; </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload