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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:22:28+00:00 2026-05-26T08:22:28+00:00

I have an MVC3 Project in C#.Net. I have Object1 with a list of

  • 0

I have an MVC3 Project in C#.Net. I have Object1 with a list of Object2…

    //navigation Property(s)
    public virtual ICollection<Object2> Object2s { get; set; }

Object2 has an Object1 property and an Object1_Id property

    public int Object1_Id { get; set; }
    public virtual Object1 Object1 { get; set; }

When I run the Index View for Object2 I get the message “Invalid column name ‘Object1_Id1′”. Weird….it’s looking for an automated column. When I remove the Object1_Id from Object2, it does fine until I go to Save in the Create View. It then throws an error message:

{"Cannot insert the value NULL into column 'Object1_Id', table 'dbo.Object2'; column does not allow nulls. INSERT fails.\r\nThe statement has been terminated."}

I’m sure I’m just missing an easy step. Any ideas?

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

    I figured out my question. When I call the Create post action on my Object2 Controller, I retrieve the parent Object1, create a Guid for my new Object2, add the new Object2 to the Object1.Object2s collection, set Object1 state to modified, then save the db:

                var object1ToUpdate = db.Object1s.Where(
                        aObject1 => aObject1.Id.Equals(myId)
                    ).Include(aObject1 => aObject1.Object2s).Single();
                string id = Guid.NewGuid().ToString();
                Object2.Id = Guid.NewGuid();
                object1ToUpdate.Object2s.Add(Object2);
                db.Entry(object1ToUpdate).State = EntityState.Modified;
                db.SaveChanges();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a ASP.NET MVC3 Razor project I have 2 Models public class Post {
I have a very simple .NET MVC3 project set up using jquery mobile for
I have a MVC3 ASP.NET Project in which I am using jQuery and KendoUI
In an ASP.NET MVC3 project I have a structure like this: Core.csproj -> 3rdparty1.dll
i have a problem with the asp.net MVC3. when i create a new project
I'm creating a project from the book Sanderson Pro ASp.net mvc3. But I have
First some context: I have an MVC3 .net project which, for the sake of
I have some C# code in my ASP.NET MVC3 project that's throwing an exception
In my solution I have an ASP.NET MVC3 project, and a WCF project that
I have a custom ValidationAttribute in my ASP.NET MVC3 project which has two conditions

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.