I have a code first EF model class like this:
public class ContentEntry
{
[Key, Column(Order = 0)]
public int Id { get; set; }
[Key, Column(Order = 1)]
public string Language { get; set; }
}
Is it possible to auto increment Id
if it is 0?
For example: I want to add a dataset like
Id = 1, Language = "En"
It works fine. Then, I want to add the following:
Id = 1, Language = "De"
It works fine too. But yet, I want to add this one:
Id = 0, Language = "En"
Id
is 0, so the DB should generate an Id
for me:
Id = 2, Language = "En"
Is there no way, I know I can generate an Id
my self. But what happen if two threads try to add an element with the same Id? Can I prevent this?