Is it possible to have a primary key and another field which is not the primary key with the "auto increment" function in Entity Framework?
I found this on the web, tried it, but it does not work:
public int Id { get; set; }
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ImageId { get; set; }
In this case, the Id is always 0.
So now i'm back to this: Id
is the primary key and i use MAX(Id) + 1
to increment the ImageId
integer.
Update: I was even thinking of creating another table just for the ImageId
's. But i'm not sure it this would be an overkill or not.