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

  • Home
  • SEARCH
  • 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 7429111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:55:04+00:00 2026-05-29T08:55:04+00:00

We are using EF 4.2 in an ASP.NET app linked to an Oracle 11

  • 0

We are using EF 4.2 in an ASP.NET app linked to an Oracle 11 g database with Oracle’s EF provider.
The parent table is called CASE_PHASE and has a primary key called ID. The child table is called CASE_STAGE and has a primary key called ID. The primary keys for both inserted with a Before Insert Trigger. This question implies the trigger could be the problem.

This code looks like samples I find in Julia Lerman’s book but only inserts a new CASE_PHASE. There are no exceptions thrown but the child is not inserted.

//from the controllers CREATE with hard coded values for testing purposes
        // POST: /CasePhase/Create

        [HttpPost]
        public ActionResult Create(CASE_PHASE case_phase)
        {


            var caseStage = new CASE_STAGE
                                {
                                    CREATED_BY_USER_ID = 1604,
                                    LAST_MODIFIED_BY_USER_ID = 1604,
                                    CURRENT = 1,
                                    STAGE_ID = 1752,
                                    DATE_CREATED = DateTime.Now,
                                    DATE_LAST_MODIFIED = DateTime.Now
                                };

            if (ModelState.IsValid)
            {
                //join new stage to phase
                caseStage.CASE_PHASE = case_phase;
                //attach linked entities to context
                //debugging shows case_phase has the values it needs   
                //but caseStage does not
                db.CASE_PHASE.Attach(case_phase);
                db.CASE_PHASE.Add(case_phase);
                db.SaveChanges();

What am I missing?

  • 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-29T08:55:05+00:00Added an answer on May 29, 2026 at 8:55 am

    I made sure Visual Studio had service pack 1 after seeing the bug about changes to the StoreGeneratedPattern=”Identity” not being copied. All the primary keys are now properly identified in the model.

    Sequences had been created. After modifying the StoreGeneratedPattern I had to modify the triggers so that the insert fired when the primary key was null. It doesn’t matter what value you set the primary key to in the code. If the primary key has the Identity pattern then EF will not send the values to the database.

    This works but it’s stupid, two commits for one linked transaction

            if (ModelState.IsValid)
            {   
                //add the parent entity
                db.CASE_PHASE.Add(case_phase);
                db.SaveChanges();
                //add new child
                var caseStage = new CASE_STAGE();
                //...more variables initialized 
                //and add the foreign key to the child
                caseStage.CASE_PHASE_ID = case_phase.ID;
                db.CASE_STAGE.Add(caseStage);
                db.SaveChanges();
                return RedirectToAction........
             }
    

    Using ADO DBContext and Oracle Entity Framework Beta (I don’t expect different behaviour in the production release that is now out because the trigger/sequence idea that Oracle uses does not seem to mix well with EF.

    Alternately you could leave the ID fields to the default setting for StoreGeneratedPattern and then get a Primary key direct from the database using a Database.SqlQuery. Add it to the parent and then add it as the foreign key to the child.

    You can take your pick: one select sequence from dual and one db.SaveChanges which at least adheres to the idea of an atomic transaction or two db.SaveChanges.

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

Sidebar

Related Questions

I have an C# asp.net app using the default Sql MembershipProvider. My web.config has
My asp.net app has is using a web.config for common configuration. I also have
I've got an ASP.NET app using NHibernate to transactionally update a few tables upon
I'm writing an app using asp.net-mvc deploying to iis6. I'm using forms authentication. Usually
I'm developing an ASP.NET app (C#) that connect to SQL Server 2008 using ADO.NET
If I am using Windows Authentication in an ASP.NET app, and I want to
I have an ASP.NET app that sits on our intranet, using the WindowsIdentity to
I am embedding a report into my ASP.NET app using the report viewer control.
We are about to develop a web app from scratch using ASP.Net, and would
I'm trying to do a proof of concept app for my work using ASP.NET

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.