title: Storing DateTime property instead of byte array in SQL table using Code-First MVC5 EF6
body: <p>When I try to initialize my database using EF6 in MVC5 I get the error: <strong>The property 'Timestamp' is not a Byte array. IsRowVersion can only be configured for Byte array properties.</strong> Is there a way I can override the IsRowVersion using FluentAPI or is there another method to store DateTime using MVC5 EF6 or is this simply the result of using the Timestamp data annotation? I prefer to store as DateTime instead of byte array. Just for visualization Model looks like this:</p>
  
  <pre><code>    public class UserProfile : IdentityUser
      {
  
          //ctor
          public UserProfile()
          {
              Random rnd = new Random();
              int pic = rnd.Next(1, 6); 
  
              DateJoined = DateTime.Now;
              UserLevel = 4;
              ImageUrl = "/Content/Avatars/Samples/sample" + pic + ".jpg"; // or append &amp;#46;jpg which == .jpg
          }
  
          public UserProfile(string name, string url)
          {
              UserName = name;
              DateJoined = DateTime.Now;
              UserLevel = 4;
              ImageUrl = url;
              Email = "your@email.com";
          }
  
          public UserProfile(string name, string url, string email)
          {
              Random rnd = new Random();
              int pic = rnd.Next(1, 6);
              UserName = name;
              DateJoined = DateTime.Now;
              UserLevel = 4;
              ImageUrl = "/Content/Avatars/sample" + pic + ".jpg"; // or append &amp;#46;jpg which == .jpg
              Email = email;
          }
          [Key]
          [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
          public int UserId { get; set; }
          [Required(ErrorMessage="*Username is required."), RegularExpression(@"^[\p{L} \p{Nd}_]+$")]
           [MinLengthAttribute(5, ErrorMessage="Not enough characters! UserName must be at least 5 chars."), MaxLengthAttribute(30,ErrorMessage="Too many characters in UserName!")]
          public override string UserName { get; set; }
          [Required(ErrorMessage="*Email is required."), EmailAddress, RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*")]
          [DataType(DataType.EmailAddress)]
          [Display(Name = "Email address")]
          public string Email { get; set; }
          [ScaffoldColumn(false),Required]
          public string ImageUrl { get; set; }
          [DisplayFormat(DataFormatString = "{0}")] //{0:d} or {0:D}
          [DataType(DataType.DateTime), Timestamp, ScaffoldColumn(false)] //&lt;--Problem 
          public DateTime DateJoined { get; set; }
          [Range(1, 6), ScaffoldColumn(false)]
          public int UserLevel { get; set; }
          [ScaffoldColumn(false)]
          public int? TotalRepPoints { get; set; }
          [ScaffoldColumn(false)]
          public virtual IDictionary&lt;int, int&gt; TotalPointsByCat { get; set; }
          // int = CategoryId, int = UserRank
          public virtual IDictionary&lt;int, int&gt; Rankings { get; set; }
          public virtual ICollection&lt;Article&gt; Articles { get; set; }
          public virtual ICollection&lt;Answer&gt; Answers { get; set; }
          public virtual ICollection&lt;Vote&gt; Votes { get; set; }
          public virtual ICollection&lt;Question&gt; Questions { get; set; }
  
      }
  </code></pre>
  
  <p>When I use NuGet Console:</p>
  
  <pre><code> PM&gt; Enable-Migrations -Force
  Checking if the context targets an existing database...
  System.InvalidOperationException: The property 'Timestamp' is not a Byte array. IsRowVersion can only be configured for Byte array properties.
     at System.Data.Entity.ModelConfiguration.Configuration.ConventionPrimitivePropertyConfiguration.IsRowVersion()
     at System.Data.Entity.ModelConfiguration.Conventions.TimestampAttributeConvention.Apply(ConventionPrimitivePropertyConfiguration configuration, TimestampAttribute attribute)
     at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
  ...
      The property 'Timestamp' is not a Byte array. IsRowVersion can only be configured for Byte array properties.
      PM&gt; 
  </code></pre>
  
  <p>Thanks in advance!</p>
  
  <hr>
  
  <p><strong>EDIT</strong></p>
  
  <p>When storing properties using data annotation  <code>[DataType(DataType.DateTime)]</code>
  with <code>DateTime?</code> class you will get datetime type field in SQL.</p>
  
  <p>When storing properties using data annotation <code>[Timestamp]</code>
  with <code>byte[]</code> you will get timestamp type field in SQL.</p>
  
  <p><img src="https://i.stack.imgur.com/e39fP.png" alt="enter image description here"></p>