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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:31:11+00:00 2026-05-27T18:31:11+00:00

(Apress PRO: ASP.NET MVC 3 Framework – by Adam Freeman and Steven Sanderson –

  • 0

(Apress PRO: ASP.NET MVC 3 Framework – by Adam Freeman and Steven Sanderson – third edition)

(As a heads-up: I am new to ASP.NET and building multi-project solutions in Visual Studio.)

I’ve been following along very well in the book up to page 298. (I am using SQL Express.) I’ve hit a snag when I try to compile and run my solution in Visual Studio 2010 (SP1).

The issue occurs when I add the ADO.NET Entity Data Model (.edmx file) to my SportsStore.Domain project under Concrete/ORM/ folder (which is odd… the book on page 291 makes it sound like that file should have already existed…)

… and I update/refresh the model in the Entity designer to include the two new properties (ImageData and ImageMimeType) –> the compiler throws an exception under:

using SportsStore.Domain.Abstract;
using SportsStore.WebUI.Models;
using SportsStore.Domain.Entities;

namespace SportsStore.WebUI.Controllers {
    public class ProductController : Controller {

        public ViewResult List(string category, int page = 1) {
            ProductsListViewModel viewModel = new ProductsListViewModel {
                Products = repository.Products
                    .Where(p => category == null || p.Category == category)
                    .OrderBy(p => p.ProductID)
                    .Skip((page - 1) * PageSize)
                    .Take(PageSize),
                PagingInfo = new PagingInfo { 
                     CurrentPage = page,
                     ItemsPerPage = PageSize,
                     TotalItems = category == null ?
                         repository.Products.Count() :
                         repository.Products.Where(e => e.Category == category).Count()
                },
                CurrentCategory = category
            };

            return View(viewModel);
        }
    }
}

saying “Could not find the conceptual model type for SportsStore.Domain.Concrete.ORM.Product.“

When I remove the .edmx file, the solution compiles successfully –> but of course, I cannot use the new image properties to add pictures to the database. Page 291 states why: no connection between new columns in Product Table and Product class. (I can find and select an image (on disk) on the webpage and hit submit, but nothing is added to the database afterwards.)

I’m not sure where to start really. If it would help to show more of my project I definitely will. (it’s pretty much identical to the book’s.)

(There actually was another snag with the Product class under SportsStore.Domain.Entities. The “ActionResult Edit(…)” method from AdminController under SportsStore.WebUI.Controllers did not like Product’s ImageData property being declared as byte and not byte[]. I fixed that of course. Should I report that in the book’s errata?)

  • 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-27T18:31:12+00:00Added an answer on May 27, 2026 at 6:31 pm

    I went through the same problem and here is how I fixed it.

    1. Do not add the edmx file
    2. Update the SaveProduct method in EFProductRepository.cs

    Something like this:

    public void SaveProduct(Product product)
        {
            if (product.ProductID == 0)
            {
                context.Products.Add(product);
            }
            else
            {
                Product prod = context.Products.Where(p => p.ProductID == product.ProductID).FirstOrDefault();
                prod.Category = product.Category;
                prod.Description = product.Description;
                prod.ImageData = product.ImageData;
                prod.ImageMimeType = product.ImageMimeType;
                prod.Name = product.Name;
                prod.Price = product.Price;
            }
            context.SaveChanges();
        }
    

    I think this is not the best way to do it, because we do the mapping by hand.

    EDIT: better way for doing it

    public void SaveProduct(Product product)
        {
            if (product.ProductID == 0)
            {
                context.Products.Add(product);
            }
            else
            {
                context.Entry(product).State = EntityState.Modified;
            }
            context.SaveChanges();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading Pro ASP.NET MVC 2 Framework by Steven Sanderson (Apress) and I
I've been learning the ASP.NET MVC framework using the Apress book Pro ASP.NET MVC
I working my way through the Apress Pro ASP.NET MVC Framework ( http://www.apress.com/book/view/9781430210078 )
I'm reading Apress Pro ASP.NET MVC Framework and there are some LINQ to SQL
I'm reading Pro ASP.NET MVC 3 Framework by Apress. I'm following the example of
I am currently working out of the Pro Asp.net mvc3 Framework book by Adam
I have been following the SportsStore example project in Apress Pro ASP.NET MVC 3
I have an app, modelled on the one from Apress Pro ASP.NET MVC that
I have created a new ASP.NET MVC project using the MVC Project Template. According
I am going though the Apress ASP.NET MVC 3 book and trying to ensure

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.