I tried filling in a table I generated using EF Core with values through Microsoft SQL Management Studio, since the list was predefined and wouldn't require editing in the future. I got the error I wrote in the title inside the console of SSMS.
I managed to resolve the issue by writing SET IDENTITY_INSERT Countries ON
above the script that would insert all the values.
This problem seems to have to do with the primary key attribute.
My question is: how do I fix this using EF Core methods, instead of the SET IDENTITY_INSERT ON
SQL command, and what exactly is the issue?
Problem table:
public class Country
{
public string Code { get; set; }
[Required]
public int Id { get; set; }
public string LongName { get; set; }
[Required]
public string Name { get; set; }
}