title: Are SQL Server computed primary key columns supported in Entity Framework 4? Exception thrown when inserting record
body: <p>Are Sql Server computed primary key columns supported when inserting/updating records with Entity Framework 4.0? I know <a href="https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql/linq/how-to-represent-computed-columns" rel="nofollow noreferrer">they're not in Linq to SQL</a>.  </p>
  
  <p>Every time I try to insert a record that has a computed primary key column defined in Sql Server, I get the error </p>
  
  <blockquote>
    <p>"Modifications to tables where a primary key column has property 'StoreGeneratedPattern' set to 'Computed' are not supported. Use 'Identity' pattern instead. "</p>
  </blockquote>
  
  <p>even when the key's StoreGeneratedPattern property is set to Identity or Computed.</p>
  
  <p>Example Table:</p>
  
  <pre><code>CREATE TABLE [dbo].[Table](
  [B1] [varchar](10) NOT NULL,
  [L1] [varchar](5) NOT NULL,
  [L2] [varchar](5) NULL,
  [E1] [varchar](7) NOT NULL,
  [D1] [varchar](50) NULL,
  [R1] [varchar](max) NULL,
  [Z1] [varchar](5) NULL,
  [D2] [varchar](5) NULL,
  [Key]  AS (([E1]+[B1])+[L1]),
  CONSTRAINT [PK_Table_1] PRIMARY KEY CLUSTERED 
  (
     [Key] ASC
  )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, 
  ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
  GO
  </code></pre>
  
  <p>Example edmx :</p>
  
  <p><a href="https://i.stack.imgur.com/hsSYw.png" rel="nofollow noreferrer">EDMX with Key properties displayed</a></p>
  
  <p>I would've just set up a normal auto-increment ID column in the database, but I've inherited this project and have been told to leave the database structure alone. </p>