Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7712387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:37:03+00:00 2026-06-01T01:37:03+00:00

I have a VS11 beta WPF application with a Microsoft Datagrid based on a

  • 0

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.

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?

The error message is pasted at the end. Thanks for any help or insight on this.

(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:
Convert DBContext to ObjectContext for use with GridView). 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.

Error
Cannot implicitly convert type
‘System.Data.Entity.DbSet’ to
‘System.Data.Objects.ObjectQuery’

Documents\Visual Studio 11\Projects\WpfApplication3\WpfApplication3\MainWindow.xaml.cs

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;

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:37:04+00:00Added an answer on June 1, 2026 at 1:37 am

    The code gnerated by drag and drop in the WPF designer was never very good and the WPF team haven’t updated it to work with DbContext. Your best bet is either to drop down to ObjectContext like the other answers suggest or to use the much better WPF data binding supported by DbContext but do so without using drag-and-drop.

    WPF data binding with DbContext is pretty easy because the Local property of each DbSet is actually an ObservableCollection which WPF naturally binds to very well. So for example you end up binding your view sources something like this:

    categoryViewSource.Source = _context.Categories.Local;
    

    This blog post contains more details: http://blogs.msdn.com/b/adonet/archive/2011/03/14/10138486.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a build script (.bat) that invokes MSBUILD ( C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\msbuild.exe ) that used
I have a SL application with many DataGrids (from Silverlight Toolkit), each on its
Have you ever seen any of there error messages? -- SQL Server 2000 Could
Have you used VS.NET Architect Edition's Application and System diagrams to start designing a
Have a n-tire web application and search often times out after 30 secs. How
Have you refactored from an ActiveRecord to a DataMapper pattern? What conditions prompted the
Have converted devise new session from erb to Haml but doens't work, this is
Have a bunch of WCF REST services hosted on Azure that access a SQL
I have Visual Studio 11 Ultimate and I am trying to develop sample application
Have a bunch of classes which I need to do serialize and deserialize from/to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.