title: Entity Framework - A null store-generated value was returned for a non-nullable member 'RowVersion' of type
body: <p>I have the following SQL to create a table:</p>
  
  <pre><code>    public const string dropCreate =
          SET ANSI_NULLS ON
          SET QUOTED_IDENTIFIER ON
          IF EXISTS (SELECT name FROM sys.objects WHERE name = 'Application' AND type = 'U')
              DROP TABLE [dbo].[Application]
          CREATE TABLE [dbo].[Application] (
              [ApplicationId] INT IDENTITY (1, 1) NOT NULL,
              [Name] NVARCHAR (50) Not NULL,
              [RowVersion] [varbinary](max) NULL,
              [ModifiedDate] [datetime] NOT NULL,
              CONSTRAINT [PK_dbo.Application] PRIMARY KEY CLUSTERED ([ApplicationId] ASC)
          )";
  </code></pre>
  
  <p>Here's my class:</p>
  
  <pre><code>public partial class Application
  {
      public Application()
      {
          this.TestAccounts = new List&lt;TestAccount&gt;();
      }
  
      public int ApplicationId { get; set; }
      public string Name { get; set; }
      public byte[] RowVersion { get; set; }
      public System.DateTime ModifiedDate { get; set; }
      public virtual ICollection&lt;TestAccount&gt; TestAccounts { get; set; }
  }
  </code></pre>
  
  <p>Mapping:</p>
  
  <pre><code>    public ApplicationMap()
      {
          // Primary Key
          this.HasKey(t =&gt; t.ApplicationId);
  
          // Properties
          this.Property(t =&gt; t.Name)
              .IsRequired()
              .HasMaxLength(35);
  
          this.Property(t =&gt; t.RowVersion)
              .IsRequired()
              .IsFixedLength()
              .HasMaxLength(8)
              .IsRowVersion();
  
          // Table &amp; Column Mappings
          this.ToTable("Application");
          this.Property(t =&gt; t.ApplicationId).HasColumnName("ApplicationId");
          this.Property(t =&gt; t.Name).HasColumnName("Name");
          this.Property(t =&gt; t.RowVersion).HasColumnName("RowVersion");
          this.Property(t =&gt; t.ModifiedDate).HasColumnName("ModifiedDate");
      }
  </code></pre>
  
  <p>I do an insert as follows:</p>
  
  <pre><code>       new TestAccount 
         { 
             Application = app ,
             Name = applicationName, 
             ModifiedDate = DateTime.Now 
         };
  </code></pre>
  
  <p>It's giving me the following exception</p>
  
  <p>InnerException: System.Data.Entity.Infrastructure.DbUpdateException
         HResult=-2146233087
         Message=A null store-generated value was returned for a non-nullable member 'RowVersion' of type 'Relational.Mappings.Contexts.Application'.
         Source=EntityFramework</p>
  
  <p>Can someone give me some advice on this. As far as I know I have set everything up correctly. </p>