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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:20:32+00:00 2026-05-18T06:20:32+00:00

I have a situation where business requirements dictate that all data access is done

  • 0

I have a situation where business requirements dictate that all data access is done via stored procs. I chose to use Entity Framework because I knew the Stored Procedure support was greatly improved in 4.0

However, I have a set of procedures which include some extra params (UserName, ReasonCode, etc…) that will be used for additional logic in the proc. This is a pretty common scenario so I am astounded that EF makes it so incredibly difficult to achieve this.

As I see it my only options for getting around this are as follows:

  1. Create a view in the database that queries the underlying table, and includes the extra column names with null values.
  2. Handle the SaveChanges event, or override the SaveChanges method on the context and manually handle the function calls there.

Option 1 is out of the question on my current project, although it would be the easiest.

Option 2 is an incredible amount of work. The whole point of EF is to save me from having to write mind-numbingly tedious data access code that will be error prone. Let’s look at the potential amount of work involved here:

  1. Create a function import for each entity needing this info, and for each modification action necessary (Insert, Update, Delete)
  2. Create some common type that holds all that information, and apply it to each entity via partial classes.
  3. Write a mapping function for each method for every entity (3*N) Note that this also involves getting original values for Update and Delete
  4. Override the SaveChanges method to inspect each Entity to see if it is the correct IFoo interface, check the state of the entity, and then call the appropriate method for that entity type.

Am I missing something??? Why would such a common scenario be so difficult to perform.

I know someone is probably thinking I could write a T4 template to generate all this code for me, but that just brings me back to the point that it is tedious boilerplate code that adds no real value. There simply has to be an easier way to just say:

“Yo EF! I am calling a proc! I know what i’m doing and I want to add these extra values in capiche?”

Extra info for the curious:

  • I’m using the Self-Tracking entities template with WCF
  • The additional params do not exist anywhere that can be linked to by the Entity
  • The additional params are always the same
  • The stored procedures are as is, they cannot be modified from their current contract

Any help or insight into this matter would be most welcome!

Cheers,
Josh

  • 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-18T06:20:33+00:00Added an answer on May 18, 2026 at 6:20 am

    The whole point of EF is to save me
    from having to write mind-numbingly
    tedious data access code that will be
    error prone.

    Right, and the way it does this is by writing the boilerplate code for you, using a T4 transform.

    I know someone is probably thinking I
    could write a T4 template to generate
    all this code for me, but that just
    brings me back to the point that it is
    tedious boilerplate code that adds no
    real value.

    … which is why leveraging T4 seems like an obvious way to solve this problem. The code you’re describing is no more tedious than the code that the Entity Framework is already generating for you. You can actually change your entity contexts so that the .edmx.cs files are generated by your own custom T4 template in the first place, rather than by Visual Studio’s built-in transform.

    I’ve not had to use stored procedures in Entity Framework yet, so there may be a better way to do what you’re describing, but I wouldn’t be too quick to discount the T4 approach if it can solve your problems adequately.

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

Sidebar

Related Questions

I have the following situation: after clicking a button, some business logic is done
I have a situation. In my project the data model is controlled by business
I have situation, where running a query that filters by an indexed column in
I have situation where a user can manipulate a large set of data (presented
We have situation where say we have four engineers that are working on software
I have a type with about 40 properties (all value types) that represents a
I have a business model called Customer which has many required properties (via DataAnnotations)
I have a Search model and controller. The business logic is that if the
I have a situation where I need to keep track of all changes to
I've got a situation where I have a business object with about 15 properties

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.