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

The Archive Base Latest Questions

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

I do have defaults set to the fields in SQL Server. Now I’m using

  • 0

I do have defaults set to the fields in SQL Server. Now I’m using LINQ to access/append/modify and delete records in my table but I wondering why do I need to assign values to the fields that I have a default value upon insertion. Consider this line of code.

SQL

CREATE TABLE SampTable
(
 sysid int not null primary key identity(1,1),
 values1 bigint not null default(0), --> consider my default is predefined
 values2 datetime not null default(getdate())
)

C# using LINQ

SampleTable entity = new SampleTable();
entity.values1 = 1;
entity.values2 = DateTime.Now  //I do have default set on sql why do i need to do this
//Do Something
  • 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-27T05:36:55+00:00Added an answer on May 27, 2026 at 5:36 am

    The ORM mapper you use (perhaps DBML) does not copy the default constraint from the database. Not a bad thing– what would happen if you changed the default in the database? Some old code might still have a copy from the old default in it’s ORM! That could get fairly confusing.

    I’d suggest to start writing SQL yourself. SQL is not half as hard as writing or customizing an ORM. Either a stored procedure or an insert statement in C# code would work.

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

Sidebar

Related Questions

I have got 2 fields in my db(sql server 2008) namely updateDate[Datetime] & calldate[datetime].
i have a question about using GalleryView. At first, i set five default images
I'm experiencing something a bit strange. I have a table on SQL Server 2008,
So I have about 150 SQL Server 2005 databases all mostly copies of each
I'm helping implement a SQL Server 2008 database and I have several columns that
I have installed SQL Server 2005 Express with/on the time I installed some software
Hi I have an SQL Server table as below CREATE TABLE [dbo].[Location]( [LocationUID] [uniqueidentifier]
I have a Linq to SQL EntitySet with a Foreign Key Relationship between two
I have an input field that is by default set to type=text so that
I have set my default-input-method variable to english-dvorak: (custom-set-variables '(default-input-method english-dvorak)) When I launch

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.