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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:54:44+00:00 2026-05-12T05:54:44+00:00

Please read here and here to get a quick overview of my problem and

  • 0

Please read here and here to get a quick overview of my problem and to see exactly what I mean when I say Model Binding from Ajax.

Would it be a bad idea to make the foreign key fields nullable in order to allow for Model Binding from javascript?

For example, we want to bind to a Person object during an ajax call to… (The Person class is created from the Entity Framework)

public ActionResult Create(Person personToCreate)
{
    //Create person here
}

If the Person had a Pet object that was a foreign key in the db, you can’t pass the Pet object along with the other data from the ajax call. So unless the Pet is nullable in the DB, binding to Person wouldn’t work.

So what I want to know is… in order to do Model Binding, should/can I null the db fields I can’t pass from javascript? Or do I have to make a Custom Model Binder and bind to a “Flatter” version of the object in order to follow best practices? example of flatter version of the object:

public class SimplePerson() {
   private string firstName;
   private string lastName;
   private string petName;
}

The reason I ask this is because a lot of my Entity Framework created classes contain foreign keys, which means I’ll need to create a flat duplicate of nearly all of those classes, and it seems to go against the whole DRY principal.

  • 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-12T05:54:44+00:00Added an answer on May 12, 2026 at 5:54 am

    I read over what you linked and posted, I can’t really think of a good solution off the top of my head, but the whole concept of changing your underlying database for the sake of AJAX makes me uncomfortable. I know that’s not a great answer, I’m struggling with several EF design issues right now myself, and there have been several times when I’ve been tempted to modify the database for the sake of the model, but doing that has always come back to bite me in the past.

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

Sidebar

Related Questions

[I did see the similar problems solved with AJAX/jQuery, so please read on]. I
I read here some topics how to get properties values from an object. In
Here is what I got so far. Please read the comment in the code.
This is my homework, but please read my problem description first. I have to
For reference, please visit this page here . When trying to get a view
I read here and there about touch but I can't get to it completely.
please I have the same problem as I found here MySQL - Selecting data
Problem Partically solved: please read bottom The variadic function in question, stripped down to
Please read my update at the end of question after reading the answers: I'm
please read carefully because my english is not good, and the question has not

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.