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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:57:36+00:00 2026-06-16T22:57:36+00:00

I have a client-side graph of entities that I’m trying to save. When I

  • 0

I have a client-side graph of entities that I’m trying to save. When I try to add add the entity (described below), Breeze reports the error of the title.

I am able to exclude/include the entity on demand and so have been able to let Breeze persist everything else in the graph and then lastly try to add this entity. The error is reported consistently.

I captured the JSON representation of the entity in the controller’s saveBundle and am able to manually insert it into the database which gives me some assurance that it’s being created correctly.

I’m stuck as to how to debug it further and would appreciate some guidance.

Here’s the code-first class (requireds: DateTime, value, Message, User):

public Guid ID { get; set; }

public Guid MessageID { get; set; }
public Guid UserID { get; set; }

public DateTime DateTime { get; private set; }
public float Value { get; set; }

public virtual Message Message { get; set; }
public virtual User User { get; set; }

public virtual ICollection<PropertyValue> PropertyValues { get; set; }

Here’s the saveBundle:

{
  "entities": [
    {
      "ID": "cdc7a329-1ddc-4535-98f1-fd878af48823",
      "MessageID": "57e88bc1-edc2-4905-af74-09df83edeba5",
      "UserID": "1269a0ad-1019-471c-bdf9-a6e61aea468c",
      "DateTime": "2013-01-04T23:32:01.067Z",
      "Value": 0,
      "entityAspect": {
        "entityTypeName": "Score:#MyProjectName.Repo",
        "entityState": "Added",
        "originalValuesMap": {},
        "autoGeneratedKey": {
          "propertyName": "ID",
          "autoGeneratedKeyType": "Identity"
        }
      }
    }
  ],
  "saveOptions": {
    "allowConcurrentSaves": false
  }
}

Here’s the SQL:

insert into Scores (
    [MessageID],
    [UserID],
    [DateTime],
    [Value]
) values (
    '57e88bc1-edc2-4905-af74-09df83edeba5',
    '1269a0ad-1019-471c-bdf9-a6e61aea468c',
    '2013-01-04T23:28:18.872Z',
    0
)

UPDATE

The server’s version of events begins with a “System.ArgumentNullException”

Value cannot be null.\r\nParameter name: source

and:

at System.Linq.Enumerable.Select[TSource,TResult](IEnumerable`1 source, Func`2 selector)
at Breeze.WebApi.EFContextProvider`1.SaveChangesCore(Dictionary`2 saveMap)
at Breeze.WebApi.ContextProvider.SaveChanges(JObject saveBundle)
at [MyProject].[MyController].SaveChanges(JObject saveBundle) in ..\Controllers\[MyController].cs:line 53
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>c__DisplayClass5.<ExecuteAsync>b__4()
at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)
  • 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-16T22:57:37+00:00Added an answer on June 16, 2026 at 10:57 pm

    I’d say that the stack trace in your updated question confirms that the exception occurs on the server.

    Looking at source for EFContextProvider, the exception you’re reporting appears to be thrown in EFContextProvider.SaveChangesCore, within the foreach that processes EF validation errors (~line 125). It is preparing a message about the entity validation error from EF’s saveChanges and failing (unexpectedly) because there are no EntityKeyValues for the key of the errant entity. That shouldn’t be possible (ha)! It would seem that EF was asked to save an entity with no key.

    You could help us diagnose as follows:

    1. Create a new EFContextProvider2 class in your Models project
    2. Paste in copy of the EFContextProvider from GitHub source.
    3. Be sure to rename the class EFContextProvider2 and make the project compile
    4. Substitute EFContextProvider2 in your Web API controller
    5. Set a breakpoint on line 124, just before it formats the key
    6. Repro the problem under the debugger

    Inspect the key.EntityKeyValues. I bet they are null for an offending entity. What entity is that? What is in the error’s eve.ValidationErrors? How is this particular entity defined in your model?

    We (well, YOU) will know a lot more when you’ve got more information about the error.

    Let us know what you discover.

    Updated Jan 9

    Now that I’ve seen a little of the code, the problem is more obvious to me.

    Your server-side model says that the Score.Message and Score.User properties are required. Well they aren’t present in the EF context on the server so you are failing validation.

    Score.Message and Score.User are navigation properties that return related Message and User objects respectively.

    When you save, EF is dutifully validating that those related entities are present. Well they aren’t. They aren’t because you (correctly) turned lazy-loading off which means EF can’t retrieve them.

    It matters not at all whether those entities are in cache on your Breeze client. Breeze will not send them up to the server as part of the save bundle.

    Nor should it do so! You are saving a new Score. But you didn’t change the Score’s related Message or User. Therefore, the only entity that needs saving is the Score. Which is why it is the one and only entity in your save bundle.

    EF is doing exactly what you told it to do: scream if there is no related Message or User.

    My question to you is: why are you requiring the Message or User? The Score has their foreign keys. Are you trying to ensure that those keys are valid? That they reference actual Message and User rows in the database? Seems like overkill to me. The database will ensure that for you if you have referential constraints turned on. If those constraints are off, then these validations will protect you during the Score insert/update; but they won’t stop someone from deleting the Message or User independently … thus orphaning the Score.

    If you insist, you can satisfy EF by LOADING those properties explicitly in a BeforeSave… method. I’ll assume you have the EF chops to do that … else you can find that out on line.

    But, as I said, this seems like overkill to me.

    BTW, commenting out the [Required] attributes on the Score’s Message and User properties freed EF to save the new Score. The app blew up back on the client for other reasons (console.debug was undefined in my environment) but I’ll leave that to you.

    Your Model

    How did you get this model. Score looks like it was generated from something. I’m not familiar with MVC scaffolding so forgive my ignorance. But I know ugly when I see it and that business of two partial classes, one of which holds the metadata "buddy" class … now that’s ugly. And many (if not most) of the attributes are superfluous.

    I can’t think of a good reason for all that cruft. What is wrong with a single, simple POCO-ish class, adorned with validation attributes on the right properties. Do this and your model will be much easier to understand.

    What’s with the jQuery deferred?

    I realize its off topic but I see you’re going to a lot of effort to turn Q promises into jQuery deferreds? That’s your choice. But there’s nothing you can do with deferreds that you can’t do as well or better with Q. You can cut out a lot of ugly code if you stick with Q. Just saying.

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

Sidebar

Related Questions

We have a client side application (Java/Swing) that we need an HTML rendering control
Suppose I have a client side app that sends out requests to a rails
I am trying to have my client side validation (model binding) to support different
We have a number of different old school client-server C# WinForm client-side apps that
I have client side date validation that requires one particular Date to be one
I'm trying to have client-side validation errors show up inline, using the client_side_validations gem
I have client-side validations on a form that are outputting as label tags. They
I have a client-side application that uses log4net's RollingFileAppender and that can be instantiated
I have some client-side JavaScript code and want to check that file for syntax
I have a client-side security policy, with a statement that grants permissions. I want

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.