Menu

Entity Framework error: Cannot insert explicit value for identity column in table

Written by

Issue

Entity Framework error: Cannot insert explicit value for identity column in table.

Cannot insert explicit value for identity column in table ‘tablename’ when IDENTITY_INSERT is set to OFF.

 

Solution

using System.ComponentModel.DataAnnotations.Schema;

[Key]

[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]

public decimal Identity_Col { get; set; }

 

Article Categories:
Asp.Net · C#

Comments are closed.

Shares