If I have a model with a key of type Guid
, is it bad practise to set the ID explicitly in the constructor?
I know it will be set implicitly by Entity Framework, but will anything bad happen (perhaps performance wise) from setting it explicitly?
Example:
class MyModel
{
public MyModel()
{
Id = Guid.NewGuid();
}
[Key]
public Guid Id { get; set; }
}
I'm thinking a Guid
is backed up by a sequential ID in SQL server, and if I set a value explicitly, I suppose I will decrease indexing performance because it will no longer be sequential?
I have not been able to find an answer on this and I am highly curious about it.
uniqueidentifier