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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:24:12+00:00 2026-06-16T20:24:12+00:00

Using Entity Framework 5 , Visual Studio 2010 with the Entity Framework Power Tools

  • 0

Using Entity Framework 5, Visual Studio 2010 with the Entity Framework Power Tools (Beta 2) extension.

Here is my database table structure:

Database Table Structure

I used the Reverse Engineer Code First function of the aforementioned extension, which generated the POCO classes and some ‘mapping’ files (not sure if that’s the formal parlance) and a single DbContext-derived class. Other than the change I describe next, all of these generated classes are as-generated by the power tool.

In the Category.cs file, I added the following code to help flatten the object graph a bit:

private ICollection<Product> m_Products = null;
public ICollection<Product> Products
{
    get
    {
        if (m_Products == null)
        {
            m_Products = new List<Product>();
            foreach (var categoryProduct in CategoryProducts)
            {
                m_Products.Add(categoryProduct.Product);
            }
        }
        return m_Products;
    }
    set { m_Products = value; }
}

I get the following exception, which I know must have something to do with the mappings, but I just can’t quite figure this out.

Unhandled Exception: System.Data.EntityCommandExecutionException: An error occurred while 
executing the command definition. See the inner exception for details.
 ---> System.Data.SqlClient.SqlException: 
      Invalid column name 'Category_CategoryId'.

If I need to post more information, such as the specifics of the mappings, just let me know and I’ll do it. I wanted to keep this as short as possible, but I realize I’ve omitted some things that, for those unfamiliar with the code generated by the tool, may leave one wanting for more details.

  • 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-16T20:24:14+00:00Added an answer on June 16, 2026 at 8:24 pm

    You’ve added a navigation property to your model and so EF is trying to map that to your database. “Code First” means your code model defines your database schema.

    Try adding the [NotMapped] attribute to your helper properties to tell EF to ignore them.

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

Sidebar

Related Questions

I am using Entity framework with following tools: MS Visual studio 2010 Professional SP1
I'm using Entity Framework in Visual Studio 2010 Beta 2 (.NET framework 4.0 Beta
Using Entity Framework Power Tools Beta 2 extension , it generates model classes with
I am using the latest beta of Visual Studio 2010 and the Entity Framework.
I am using Entity Framework, C# 4.0 and Visual Studio 2010. I need to
I'm using Visual Studio 2010 RTM with .NET/Entity Framework 4 RTM with a model
To begin with: Using Entity Framework v4.0. ASP.NET MVC 2.0. Visual Studio 2010. I
My scenario I'm using Visual Studio 2010 with Entity Framework 4.1 I have a
I am using MVC3, C# 4.0 and Entity Framework in Visual Studio 2010. I
I've created a web application project in Visual Studio 2010 using Entity Framework Code

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.