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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:37:31+00:00 2026-06-01T00:37:31+00:00

EF is making some properties non nullable by default in the database, is there

  • 0

EF is making some properties non nullable by default in the database, is there some way to over ride this for certain properties ? I tried searching for a data annotation but found nothing.

I am using code first the properties are an int and a datetime

  • 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-01T00:37:33+00:00Added an answer on June 1, 2026 at 12:37 am

    I am assuming that you are using code-first. You are probably getting non-nullable for types that are indeed non-nullable (value types), like int, bool, etc. You need to use the nullable version of these in order to do this:

    int? MyColumnThatIsNullable
    

    and NOT this

    int MyColumnThatIsNOTNullable
    

    Think about how the code would work and this will make sense to you. If a field is an int and a null is attempted to be passed into the code, then you will either have some sort of error, or a magic (default) value. This will not properly represent the value in the database. So, if you use the nullable version, then the null in the database can be represented for what it truly is, a null.

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

Sidebar

Related Questions

Is there some internal difference between the C# syntactic sugar way of making properties:
Is there some shortcut way of handling multiple properties on a class (say 50
I wonder if there is a non-programatical way of making log4j aware of changes
I've been making my viewmodel properties nullable for quite some time now. My reasoning
I'm making a todo list in django. I have a model with some properties:
I have a method which instantiates an object, some of the properties of this
In C#, I'm marking some classes' properties with attributes and I'm using reflection to
After making some changes in my models (eg. new field in a model and
While making some final tests of a class-library that I'm writing for Windows Mobile
im making some script with mechanize.browser module. one of problem is all other thing

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.