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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:03:19+00:00 2026-06-12T04:03:19+00:00

I’m having issues with a database uploadscript. It basically just adds all entities from

  • 0

I’m having issues with a database uploadscript. It basically just adds all entities from a backup source to the database.

However, as some fields of the new database are non-existent in the old data source, I assign them default values. See screenshot below for examples, the string property CCP1_description (and the similarly named descriptions below that) are being set to "Enter description here."

However, when I save the entity, I get an Exception saying that the description field is not allowed to be NULL. Which it clearly isn’t.

See screenshot for code + Exception

screenshot of issue

Here’s a snippet from my database creation script, it shows how the columns have been set up:

...
[CCP1_description] nvarchar(max)  NOT NULL,
[CCP2_description] nvarchar(max)  NOT NULL,
[EP1_description] nvarchar(max)  NOT NULL,
[EP2_description] nvarchar(max)  NOT NULL,
[EP3_description] nvarchar(max)  NOT NULL,
[EP4_description] nvarchar(max)  NOT NULL,
[EP5_description] nvarchar(max)  NOT NULL,
...

If I check my temp variable when debugging, I can clearly see the content of the description fields (all are ""Enter description here. like they should be.

screenshot2

I know that a lot of things can cause this exception; but I don’t see the root cause of this issue. Can someone shed some light on this? I have no idea why this exception is thrown…

I found many open questions with the same error, but I think this is a different situation because my fields are not databasegenerated, nor are they PK or IDENTITY fields. They are not empty when the entity is being constructed, and the object that is being added actually has the correct values.

UPDATE

I just noticed that the first 83 entities are added correctly. The exception is thrown on the 84th time the code is executed (and a lot of times after that.
Which means the issue is probably within another property field.

I checked all the fields, the only null values I encounter are added in fields that have been set nullable in the database and entity framework.

And now I really don’t get why an exception is thrown on the description fields.

UPDATE 2

It seems this application was coded by Salvador Dali.

I reworked the code, but this time, I commented out the .AddObject(temp); line. Which means the entities are created, but never added to the db context. The db.SaveChanges(); call should then actually be redundant and do nothing at all.

Or so I though. Turns out, my entities are still being added. I stepped through the entire code execution, it never uses the db context in any way except for the db.SaveChanges();, yet it still all gets added.
Conversely, if I only start adding the entities after a counter has reached 100 (which means only item 100, 101, 102, … will be saved, all the rest will not be added), it stil keeps adding the other entities as well.

I have no clue at all. Literally none. I’ll update the post once I know more.

FINAL UPDATE

I managed to find a workaround (see my answer below). However, I’m still looking for an explanation why this is happening. If anyone can explain this to me, I’ll award them the answer to this question.

  • 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-12T04:03:21+00:00Added an answer on June 12, 2026 at 4:03 am

    I’ve managed to get a bit further in the code. I’ve changed the order of operations. It used to be:

    //1. initialize temp
    //2. fill in temp; field by field.
    //3. if any missing (required) fields are encountered during step 2, then continue the foreach loop and take the next element (no save)
    //4. else, add to database ad save changes
    

    Somehow, And I cannot explain this, the entitiy gets saved automatically. If I run the exact same code as above but without the .AddObject() function, it still gets added.

    So I changed my code to:

    //1. Find all fields that will be needed for the entity
    //2. If any required field is stille empty, continue the foreach loop
    //3. initialize temp (inline initialization with all properties)
    //4. Add object and save.
    

    This doesn’t really solve the original problem, it’s just a workaround. If anyone can provide me with an explanation why these entities are being added, I will accvept that as the solution to my problem.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from
I have a view passing on information from a database: def serve_article(request, id): served_article
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
Does anyone know how can I replace this 2 symbol below from the string

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.