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 9110011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:10:35+00:00 2026-06-17T03:10:35+00:00

I want to create a set of DataGridView controls by dragging their respective DataSources

  • 0

I want to create a set of DataGridView controls by dragging their respective DataSources onto a form. I would do that for an object and one of its navigation properties (from the DataSources), thus having two grids in a Master-Detail relationship.

After moving to Visual Studio 2012 (and EF 5.0), the first grid comes through as expected (with the navigator). However, for the “detail” grid, only two columns appear (“Count” & “IsReadOnly”). I’ve tried it with other tables/objects and I hit the same problem. I’ve tried “Edit Columns” & “Add Column” to no available.
I use northwind as an example. I want 2 datagridview in a form. one for a customer and another for related orders. a typical master/details view.

  1. I added a model to project (edmx) file.

  2. added a new datasource to model. two objects. customer and orders tables!

  3. dragged customer entity as datagridview. All fields (properties) are in grid.

4 when dragging the orders from customer entity not order entity itself, there are only two column named “count” and “readonly”

Above procedures work fine in linq to sql VS 2012, EF 4.0, .NET 4.5. But NOT for EF 5.0.

and,

The steps are exactly same as the way beth massi described in http://blogs.msdn.com/b/bethmassi/archive/2008/12/10/master-details-with-entity-framework-explicit-load.aspx However this is not an issue of lazy or eager loading!

  • 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-17T03:10:36+00:00Added an answer on June 17, 2026 at 3:10 am

    In the class for the entity you are trying to work with change the navigation property type to ObservableCollection.

    From this:

    public Customer()
        {
            this.CustomerAddresses = new HashSet<CustomerAddress>();
        }
    
        public virtual ICollection<CustomerAddress> CustomerAddresses { get; set; }
    }
    

    To this:

    public Customer()
        {
            this.CustomerAddresses = new ObservableCollection<CustomerAddress>();
        }
    
        public virtual ICollection<CustomerAddress> CustomerAddresses { get; set; }
    }
    

    Since this is auto generated code you will also need to change some rules in your code generation file. Try manually making these changes to ensure they work first then make the changes. For me I had to make the following changes to my .tt file

    Add using System.Collections.ObjectModel by adding the line below that mentions that.

    return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion())
            ? string.Format(
                CultureInfo.InvariantCulture,
                "{0}using System;{1}" +
                "{2}",
                inHeader ? Environment.NewLine : "",
                includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "",
                includeCollections ? (Environment.NewLine + "using System.Collections.ObjectModel;") : "",
                inHeader ? "" : Environment.NewLine)
            : "";
    

    And change your HastSet declaration to Observable Collection

    this.<#=code.Escape(navigationProperty)#> = new ObservableCollection<<#=typeMapper.GetTypeName(navigationProperty.ToEndMember.GetEntityType())#>>();
    

    Also, change ICollection here to be ObservableCollection

    navigationProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType,
    

    Your code generation file may differ from mine but these code parts should give you an idea of what to search for in your file.

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

Sidebar

Related Questions

I want to create a set of buttons that would work and feel very
I want to create a set of options, that will be appended to every
I want to create a set of classes that are very similar and can
I want to create a custom set that will automatically convert objects into a
I want to create a method ( set ) that injects arguments into another
I want to create a postgres function that builds the set of columns it
I want to create a set of classes that share a lot of common
I want to create a set of functions, that make life easier. I use
I want to create a script that will set the file associations for mostly
Suppose I want to create a set of observers based on type. That is

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.