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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:55:20+00:00 2026-05-18T06:55:20+00:00

I’m using EF 4, WCF Data Services and Silverlight 4. I have been getting

  • 0

I’m using EF 4, WCF Data Services and Silverlight 4. I have been getting data from my service without problems. I’m trying to save entities in a batch that are defined in EF with a complex type that has non-nullable columns.
Ex:
Customer has a Complex Type of Audit. Audit has an EntryDateTime column that is marked as computed (could that be the problem?). It also has an Address field that is required. In my Silverlight app, I have a form to enter customer info and the address info.
On the save button click I do something like this:

Customer c = new Customer();
c.Name = this.nameTextBox.Text;
// more properties set....   
Customer.Audit = new Audit(){ UserId = 1, EntryDateTime = DateTime.UtcNow};
c.Address = new Address()
{
Address = this.addressTextBox.Text,
ZipCode = this.zipcodeTextBox.Text,
// more properties set....
Audit = new new Audit(){ UserId = 1, EntryDateTime = DateTime.UtcNow}
};

EDM context = new EDM(new Uri(serviceURL, UriKind.Absolute));
// add to the context for the update
context.AddToCustomers(c);
context.AddToAddresses(c.Address);

// I’m not sure if the update is needed…
context.UpdateObject(c);
context.UpdateObject(c.Address);

// manually add the link according to http://msdn.microsoft.com/en-us/library/dd756361.aspx, this must be done for the context to know about the relationship (aka association)
context.SetLink(c, "Address", c.Address);

// save the changes (batch so all the objects will get created with associations)
context.BeginSaveChanges(SaveChangeOptions.Batch, new AsyncCallback((iar) =>
{
try
{
// Callback method for the async request, retrieves the status of the requested action
DataServiceResponse response = this.Context.EndSaveChanges(iar);

// Maps the status of the requested action

bool status = true;
foreach (ChangeOperationResponse change in response)
{
if (!change.StatusCode > 200 && change.StatusCode < 300;)
{
status = false;
break;
}
}
if(!status) throw new Exception(“something wrong with the save”);

I’ve set breakpoints and have seen the entryDateTime as set (in the EF designer.cs and before the saveChanges is called), but the server is always throwing an exception that the entryDateTime is null and cannot be for a non-nullable column for a database insert.
I’ve also tried to attach and update the audit, but that didn’t help either (as I expected).

context.AddLink(customer.Audit, "Audit", customer);
context.UpdateObject(customer.Audit);

Is there something I’m missing?

EDIT: I put the question up last night very quickly as I was on my way out. Thank you for the comments and hopefully I’ve made my question clear.

  • 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-18T06:55:20+00:00Added an answer on May 18, 2026 at 6:55 am

    The problem was that in the Audit Complex Type, the EntryDateTime StoreGeneratedPattern is set to Computed, as we were trying to get the database to set this for us automatically. I went into the database and manually added GetUtcDate() to the Default value or binding and no longer get the same exception. Now the question becomes who to set a default date in the designer.

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

Sidebar

Related Questions

No related questions found

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.