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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:44:58+00:00 2026-06-16T19:44:58+00:00

I am new to entity framework and have hit an issue trying to insert

  • 0

I am new to entity framework and have hit an issue trying to insert new items into a lookup table.

The error is –

“An unhandled exception of type System.StackOverflowException
occurred in mscorlib.dll”

It is thrown in the final code block below where public DIEMEntities() is called.

It occurs whenever I add a new item, I can update items ok.

Any help would be appreciated.

The code is –

protected void OnSave(object sender, EventArgs e)
    {
        ArrayList validationErrors = new ArrayList();
        ContactTypeEO contactType = new ContactTypeEO();

        if (uxID.Value.Length > 0)
        {
            //Updating
            contactType.Id = int.Parse(uxID.Value);
        }

        contactType.Name = uxName.Text;
        contactType.ExpressionValidator = uxExpression.Text;

        contactType.Save(ref validationErrors);

        if (validationErrors.Count > 0)
        {
            ShowValidationMessages(validationErrors);
        }
        else
        {
            this.RefreshUI();
        }
    } 

public bool Save(ref ArrayList validationErrors)
    {
        ValidateSave(ref validationErrors);

        if (validationErrors.Count == 0)
        {
            if (Id == 0)
            {
                ContactTypeData.Insert(Name, ExpressionValidator);
            }
            else
            {
                ContactTypeData.Update(Id, Name, ExpressionValidator);
            }
            return true;
        }
        else
        {
            return false;
        }
    } 

/// <summary>
    /// Inserts the new Contact Type.
    /// </summary>
    /// <param name="name">The name.</param>
    /// <param name="validator">The validator.</param>
    public static void Insert(string name, string validator)
    {
        using (DIEMEntities diemEntities = new DIEMEntities())
        {
            Insert(name, validator);
        }
    }

    /// <summary>
    /// Inserts the new Contact Type.
    /// </summary>
    /// <param name="diemEntities">The DIEM Entities.</param>
    /// <param name="name">The name.</param>
    /// <param name="validator">The validator.</param>
    public static void Insert(DIEMEntities diemEntities, string name, string validator)
    {
        diemEntities.usp_ContactTypes_Insert(name, validator);
    } 

public partial class DIEMEntities : DbContext
{
    public DIEMEntities()
        : base("name=DIEMEntities")
    {
    }

... OTHER CODE}
  • 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-16T19:44:59+00:00Added an answer on June 16, 2026 at 7:44 pm

    You have a recursive loop here:

    public static void Insert(string name, string validator)
    {
        using (DIEMEntities diemEntities = new DIEMEntities())
        {
            Insert(name, validator);
        }
    }
    

    This will execute continuously until you run out of memory.

    I believe your intention is to do this:

    public static void Insert(string name, string validator)
    {
        using (DIEMEntities diemEntities = new DIEMEntities())
        {
            Insert(diemEntities, name, validator);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Entity Framework and have come across a problem while trying to
I'm new to Entity Framework and am trying to figure things out. I have
When adding a new Entity Framework object to a database, how could one have
I'm new to Entity Framework and am using Database First. I have inherited a
I have created a new application using Entity Framework 4.3 database migrations. The migrations
The goal: I'm trying to use the new Entity Framework 4.1 DbContext API (using
I’m new to the Entity Framework and have a question about ObjectContext lifecycle in
I am new to Entity Framework so please bear with me. I have a
I am fairly new to Entity framework as well as LINQ. I have used
I'm new to Entity Framework. :-) I have something similar to the following: Master

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.