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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:08:00+00:00 2026-05-22T21:08:00+00:00

I am trying to use EF with an existing DB. I brought in a

  • 0

I am trying to use EF with an existing DB. I brought in a Client table into my data model and let EF create a Client entity. I have a sproc, GetClientSearch, that only returns 5 out of the 15 columns from the Client table becuase that is all that is needed for that call.

Here’s what I’ve done so far:

  • Added the sproc to Function Imports and set the proc to map to the Client entity.

  • When I execute the proc through the Context, I get “The data reader is incompatible with the specified ‘GAINABSModel.Client’. A member of the type, ‘MiddleInitial’, does not have a corresponding column in the data reader with the same name.” exception. (MiddleInitial is not one of the columns returned in the proc)

  • I know that I can create a new entity that maps to the proc, but I don’t want to do that for every proc I have to import into my model.

  • Given that the DB is currently in use in production, changing stored procs to map to my current entities may not be an option.

Currently using EF 4 and VS 2010.

So, is there a way to map the results of the sproc to the Client entity, even though the columns returned are not 1:1 with the properties of the EF entity?

  • 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-22T21:08:01+00:00Added an answer on May 22, 2026 at 9:08 pm

    Yep, one of my many pain points in EF.

    If you can’t modify the SP’s, your best bet might be to create “wrapper” SP’s on top of the existing SP’s.

    In other words, EF-serving SP’s that call into the existing ones, and return NULL for the columns you don’t need, but are required for the entity.

    Of course the better option would be to create the entities properly.

    Another option is to use ObjectContext.Translate<T>, which basically performs a L-R between the SPROC results and the entity you supply.

    If the result set doesn’t contain the field, then the property on the object will be null.

    Which is probably what you want.

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

Sidebar

Related Questions

We are trying to use RequestFactory with an existing Java entity model. Our Java
I'm trying to use NHibernate with an existing database. In the data-model there is
I'm trying to use Node.js to create a zip file from an existing folder,
I'm trying to use migrations to add a parent table to an existing child
I'm trying to use the openedge jdbc connector to pull data from an existing
I'm trying to use the Entity Framework code first without an existing database. I
I'm trying to use LINQ to create a new dictionary from an existing one,
I am trying to use JAXB's introspection to marshall and unmashall some existing domain
I'm trying to use ThreadLocal to provide thread safety to pre-existing non-thread-safe classes, but
I've been trying to use smart pointers to upgrade an existing app, and I'm

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.