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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:29:25+00:00 2026-06-11T23:29:25+00:00

I am working on an MVC 3 application in C# that is having trouble

  • 0

I am working on an MVC 3 application in C# that is having trouble updating an entry in the table.

The update string that is being called from EF is sending in the date as such (all other values in the where statement have been removed for clarity):

where [CreateDate] = '2012-09-24 19:12:08'

The actual database entry has the date and the sql data type is datetime2(7):

2012-09-24 19:12:08.6457698

When the code is executed the dates don’t match and nothing is updated. I created my models using Reverse Engineering Code First from existing database. Here is my Model:

public class NPost
{
    [HiddenInput(DisplayValue = false)]
    public int NPostID { get; set; }

    [HiddenInput(DisplayValue = false)]
    public System.Guid UserId { get; set; }

    [Required(ErrorMessage = "Please enter a title!")]
    [StringLength(Int32.MaxValue)]
    public string Title { get; set; }

    [AllowHtml]
    [Required(ErrorMessage = "Please enter the body of the post!")]
    [StringLength(Int32.MaxValue)]
    public string Body { get; set; }

    [Required(ErrorMessage = "Please enter at least one tag!")]
    [StringLength(Int32.MaxValue)]
    public string Tags { get; set; }

    public System.DateTime CreateDate { get; set; }
    public Nullable<System.DateTime> PublishDate { get; set; }
    public Nullable<double> Rating { get; set; }

    [Required(ErrorMessage = "Please enter a topic!")]
    [StringLength(Int32.MaxValue)]
    public string Topic { get; set; }

    [StringLength(Int32.MaxValue)]
    public string TitleImage { get; set; }

    [StringLength(Int32.MaxValue)]
    public string ListingImage { get; set; }

    [StringLength(Int32.MaxValue)]
    public string BoxImage { get; set; }

    public virtual aspnet_Users aspnet_Users { get; set; }
}

What do I need to do to get these dates to line up and work correctly?

  • 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-11T23:29:26+00:00Added an answer on June 11, 2026 at 11:29 pm

    I agree with the cautions that others have expressed regarding what you’re doing here. However, we ought to have a direct answer to your question too! I suspect that EF is treating your column as a SQL datetime value rather than the newer datetime2 type. So try the following.

    You can use the [Column(TypeName = "datetime2")] attribute on your property to indicate the exact database type to use, or the HasColumnType method if you prefer fluent configuration.

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

Sidebar

Related Questions

I have an ASP.NET MVC (beta) application that I'm working on, and am having
I have an MVC application that is using MEF for the controllers, all working
I am working with an ASP.NET MVC application. I have one master page having
Ok so I'm working on an ASP MVC Web Application that queries a fairly
I'm working on an ASP.NET MVC 3 application and having some issues. I've got
I am working with an ASP.NET MVC application. There is a requirement that a
I have been working on a new MVC application that utilizies EF4, POCO Domain
I am working on an ASP.Net MVC3 application and I'm having trouble understanding the
I'm working on a three-tier application (presentation, business, persistence) and am having conceptual trouble
I'm working on a Intranet application that manipulates data from a SQL server. The

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.