What to do when the data is inserted in the database, the "ID" column is autonumber. I tried this:
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int IdMema { get; set; }
public string Autor { get; set; }
public int? Like { get; set; }
public int? Dislike { get; set; }
Properties "Memy" table:
CREATE TABLE [dbo].[Memy] (
[Id_mema] INT NOT NULL IDENTITY,
[autor] TEXT NULL,
[like] INT NULL,
[dislike] INT NULL,
PRIMARY KEY CLUSTERED ([Id_mema] ASC)
);
When I try to insert data, then I see:
"SqlException: Cannot insert explicit value for identity column in table 'Memy' when IDENTITY_INSERT is set to OFF."
How to resolve this?