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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:17:46+00:00 2026-06-18T02:17:46+00:00

I have a challenge. We have a database that was originally designed to be

  • 0

I have a challenge. We have a database that was originally designed to be used with VB6 and most of the functionality sits in stored procedures. I cannot make changes to the stored procedures as the old application will still need to work for a while and I do not have my own copy of the database that I can modify even briefly.

So is it possible to execute a stored procedure from EF and have it do it’s best to write the results into an array/collection of POCOs?

I’ve tried the database first approach and import but EF says the stored procedure does not return any columns and so cannot create a complex type. I’ve found there are ways to change the stored procedure to allow this to work but I cannot alter the database I’m using.

Another challenge is that the names of the columns in the results are things like ‘Date last changed’ in other words with spaces. How will EF try to map these? Would it become DataLastChanged or possibly Data_last_changed? Is there a way to mark my POCO with attributes to say how they are mapped?

What I was hoping for is something like

var resuls = efContext.ExecuteStoredProcedure<MyPOCOType>("spName",param1, param2, ...);

And have EF do it’s best to match the results to the type. Does such a thing exist? Incidentally we are using EF4 but I believe 5 is available to us.

  • 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-18T02:17:46+00:00Added an answer on June 18, 2026 at 2:17 am

    I think I’ve cracked part of the problem for myself. The following snippet does what I need.

    using (DbContext context = new DbContext("DBConnectionStringNameFromAppConfig"))
                {
    
                    SqlParameter[] parameters =
                          {
                                            new SqlParameter("@OwnerID", DBNull.Value),
                                            new SqlParameter("@ExternalColorID", colorOwner.ExternalColorID),
                                            new SqlParameter("@ProductionSiteID", DBNull.Value),
                                            new SqlParameter("@PanelstatusNr", DBNull.Value),
                                            new SqlParameter("@DateLastChecked", DBNull.Value),
                                            new SqlParameter("@rowcount", DBNull.Value),
                          };
                    var colors = context.Database.SqlQuery<Models.ColorSelectEvaluation>("[dbo].[sp_Color_Select_Evaluation] @OwnerID, @ExternalColorID, @ProductionSiteID, @PanelstatusNr, @DateLastChecked, @rowcount", parameters).ToList();
    
                }
    

    The confusing this is still the naming of the columns. They mostly seem to work but EF is not mapping the resulting column ‘Needs evaluation’ to the property NeedsEvaluation on my object.

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

Sidebar

Related Questions

I have a SQL Server 2008 database. This database has a stored procedure that
I have a challenge that I am trying to solve and I can't work
Challenge: I have this code that fails to compile. Can you figure out what's
I have a simple challenge with a background not animating. I have used this
I have been set a challenge to create an indexer that takes all words
I have a bit of a unique challenge today. I have a client that
I have an interesting challenge that I'm wondering if anyone here can give me
I have a legacy database with a pretty evil design that I need to
I have a database that collects client information using assessments and other tools. Often
I have this new challenge to load ~100M rows from an Oracle database and

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.