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#

Leave a Reply

Your email address will not be published. Required fields are marked *

Shares