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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:47:53+00:00 2026-05-26T12:47:53+00:00

My scenario I’m using Visual Studio 2010 with Entity Framework 4.1 I have a

  • 0

My scenario
I’m using Visual Studio 2010 with Entity Framework 4.1
I have a legacy database with many tables and many stored procedures.
I’m writing an ASP.NET C# program using MVC 3

I have adopted the ‘database first’ design using ADO.NET DbContext so I have an edmx with all the models and associations and navigation properties nicely set up.
I can map the insert, update, delete procedures to the relevant models.
I’ve used ‘Function Import’ to import other stored procedures.
However, I can’t find a way to map my Select procedures to select actions (select by id, select list, select by filter etc).

EF seems to use lazy loading so what I want to happen is when an object fetches its child objects it uses the stored procedures already written.
(The select procedures take into account an ‘IsDeleted’ flag, and use the ‘ORDER BY’ clause, amongst others)

I see from this article
http://weblogs.asp.net/scottgu/archive/2007/08/16/linq-to-sql-part-6-retrieving-data-using-stored-procedures.aspx
that Linq to SQL allows drag and drop of SPs, which sounds, more or less, exactly what I want.

I’ve also come across the term DefiningQuery.
http://msdn.microsoft.com/en-us/library/cc982038.aspx
Is this what I want? I don’t like the note ‘Any changes made to the storage model, including defining queries, will be overwritten when you run the Update Model Wizard.’

In summary, what I want to happen is when an object fetches its child objects it uses my stored procedures.

Can I achieve my goal using Entity Framework?
Have I missed something obvious?

Or should I try to be really clever and modify the db Entity T4 template, so that, for example, my generated Address model has this property:

public virtual ICollection<AddressLine> AddressLines { 
    get{
        DBWrapper _db = new DBWrapper();
        return _db.GetAddressLines(AddressID);
    } 
    set{}; 
}

where GetAddressLines is custom function that calls a function import and does the neccessary conversions.

  • 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-26T12:47:54+00:00Added an answer on May 26, 2026 at 12:47 pm

    It is not possible. You can import your stored procedures as function imports and manually execute them but you cannot replace queries generated by EF with custom stored procedures.

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

Sidebar

Related Questions

Scenario I have a server, that has NO Visual Studio Installed. It literally has
Scenario : I am using a T-SQL stored proc (Sql Server Management Studio) to
Scenario. Language C#, Unit testing using VS2008 Unit testing framework I have a static
Scenario: Let's say I have two tables, TableA and TableB. TableB's primary key is
Scenario: I am parsing values from an XML file using C# and have the
Scenario : i have a database table that is being updated frequently by some
Scenario: I have an application (C#) that expects a SQL database and login, which
Scenario: I have an application that pulls data from a SQL database as well
Scenario: I have got a client, php script and a MySQL database. I am
Scenario I'm parsing emails and inserting them a database using an ORM (NHibernate to

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.