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

  • Home
  • SEARCH
  • 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 6550661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:14:33+00:00 2026-05-25T12:14:33+00:00

Edit: Updated problem description based on testing – 12 Sep 2011. I have this

  • 0

Edit: Updated problem description based on testing – 12 Sep 2011.

I have this query that throws a NotSupportedException (“Specified method is not supported.”) whenever I call .ToList().

IQueryable<FileDefinition> query = db
    .FileDefinitions
    .Include(x => x.DefinitionChangeLogs)
    .Include(x => x.FieldDefinitions.Select(y => y.DefinitionChangeLogs)) // bad
    .Include(x => x.FieldDefinitions.Select(y => y.FieldValidationTables)) // bad
    .Where(x => x.IsActive);
List<FileDefinition> retval = query.ToList();

If I comment out either line that I have commented as “bad”, then the query works. I have also tried including different nested entities in my object model with the same effect. Including any 2 will cause a crash. By nested, I mean a navigation property of a navigation property. I also tried using the .Include methods with a string path: same result.

My table structure looks like this:

Db model

Db model 2

This is using MySQL 5.1 (InnoDB tables obviously) as the database store with MySQL Connector/NET 6.3.4.

So my question is: Why doesn’t this work?

Note: I can get it to work if I explicitly load the related entities like in this link. But I want to know why EF hates my data model.

ANSWER: MySQL Connector is apparently not capable of handling the 2nd nested entity include. It throws the NotSupportedException, not .NET EF. This same error was also present when I tried this using EF4.0, but my research at the time led me to believe it was self-tracking entities causing the issue. I tried upgrading to latest Connector, but it started causing an Out of Sync error. This is yet another reason for me to hate MySQL.

  • 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-05-25T12:14:34+00:00Added an answer on May 25, 2026 at 12:14 pm

    I have made a little console application to test your scenario and this test application works:

    using System;
    using System.Collections.Generic;
    using System.Data.Entity;
    using System.Linq;
    
    namespace EFIncludeTest
    {
        public class Parent
        {
            public int Id { get; set; }
            public string Name { get; set; }
            public ICollection<ChildLevel1> ChildLevel1s { get; set; }
        }
    
        public class ChildLevel1
        {
            public int Id { get; set; }
            public string Name { get; set; }
            public ICollection<ChildLevel2a> ChildLevel2as { get; set; }
            public ICollection<ChildLevel2b> ChildLevel2bs { get; set; }
        }
    
        public class ChildLevel2a
        {
            public int Id { get; set; }
            public string Name { get; set; }
        }
    
        public class ChildLevel2b
        {
            public int Id { get; set; }
            public string Name { get; set; }
        }
    
        public class MyContext : DbContext
        {
            public DbSet<Parent> Parents { get; set; }
        }
    
        class Program
        {
            static void Main(string[] args)
            {
                // Create entities to test
                using (var ctx = new MyContext())
                {
                    var parent = new Parent
                    {
                        Name = "Parent",
                        ChildLevel1s = new List<ChildLevel1>
                        {
                            new ChildLevel1
                            {
                                Name = "FirstChildLevel1",
                                ChildLevel2as = new List<ChildLevel2a>
                                {
                                    new ChildLevel2a { Name = "FirstChildLevel2a" },
                                    new ChildLevel2a { Name = "SecondChildLevel2a" }
                                },
                                ChildLevel2bs = new List<ChildLevel2b>
                                {
                                    new ChildLevel2b { Name = "FirstChildLevel2b" },
                                    new ChildLevel2b { Name = "SecondChildLevel2b" }
                                }
                            },
    
                            new ChildLevel1
                            {
                                Name = "SecondChildLevel1",
                                ChildLevel2as = new List<ChildLevel2a>
                                {
                                    new ChildLevel2a { Name = "ThirdChildLevel2a" },
                                    new ChildLevel2a { Name = "ForthChildLevel2a" }
                                },
                                ChildLevel2bs = new List<ChildLevel2b>
                                {
                                    new ChildLevel2b { Name = "ThirdChildLevel2b" },
                                    new ChildLevel2b { Name = "ForthChildLevel2b" }
                                }
                            },
                        }
                    };
    
                    ctx.Parents.Add(parent);
                    ctx.SaveChanges();
                }
    
                // Retrieve in new context
                using (var ctx = new MyContext())
                {
                    var parents = ctx.Parents
                        .Include(p => p.ChildLevel1s.Select(c => c.ChildLevel2as))
                        .Include(p => p.ChildLevel1s.Select(c => c.ChildLevel2bs))
                        .Where(p => p.Name == "Parent")
                        .ToList();
    
                    // No exception occurs
                    // Check in debugger: all children are loaded
    
                    Console.ReadLine();
                }
            }
        }
    }
    

    My understanding was that this basically represents your model and the query you are trying (taking also your comments to your question into account). But somewhere must be an important difference which is not visible in the code snippets in your question and which makes your model fail to work.

    Edit

    I have tested the working console application above with MS SQL provider (SQL Server 2008 R2 Express DB), not MySQL Connector. Apparently this was the “important difference”.

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

Sidebar

Related Questions

Edit: Updated code after changes I have a for loop that creates markers for
UPDATE: Solved. Thanks BusyMark! EDIT: This is revised based on the answer below from
I'm new to rails and I'm kind of stuck with this design problem, that
Problem: I have an enumerated type which has description tags in the following style:
EDIT: Updated with suggestions from Bill Karwin below. Still very slow. I'm trying to
See updated input and output data at Edit-1. What I am trying to accomplish
EDIT: Modified title and added update. UPDATE : We no longer believe this is
I have an update panel in a repeater (Edit: I removed Runat and Id
I have an Edit action and an Edit view to allow users to update
Edit: This question was written in 2008, which was like 3 internet ages ago.

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.