Inwariagreero
New Member
I'm quite new to this, I'm using MVC view model that has a property with \[code\]Datetime\[/code\] type :\[code\]namespace FP.WebUI.Models{ public class AdminSessionsViewModel { NewSession _NewSession = new NewSession(); public NewSession NewSession { get { return _NewSession; } set { _NewSession = value; } } public IEnumerable<Sessions> CurrentSessions { get; set; } } public class NewSession { [Required] public string Title { get; set; } public string Description { get; set; } [Required] public DateTime Date { get; set; } }}\[/code\]I want \[code\]Date\[/code\] property to be like this format : 27/05/2013 06:44AM and the same inside SQL database.I really don't know how to configure \[code\]Date\[/code\] inside the \[code\]NewSession\[/code\] class to automatically get shown like this inside my Textbox and when mapped back to Entity Framework will be saved inside the database like this.Here's my entity framework fluent API configuration :\[code\]namespace FP.Domain.Configurations{ public class SessionsConfig : EntityTypeConfiguration<Sessions> { public SessionsConfig() { ToTable("Sessions"); Property(p => p.Name).IsRequired(); Property(p => p.PhotosCount).IsRequired(); Property(p => p.CoverPhoto).IsRequired(); Property(p => p.Date).HasColumnType("datetime2").HasPrecision(0); } }}\[/code\]