I have a model that looks like this:
public interface IEntity { int Id { get; set; } }
Then the idea is for my objects to inherit from this interface:
public class User : IEntity { public int Id { get; set; } }
However, one of my entities actually has a Guid as an identifier.
public class UserSession { public Guid Id { get; set; } }
I really would like all my objects to inherit the same interface, but this would force me to add an integer column with a user id in UserSession, which is not needed, since Guid is an identifier, but it will save the domain model well, since all objects inherit from the same base.
What options do I have in this scenario? Can I have two basic interfaces: one for int and one for Guid? Should I add an identifier column to the UserSession element, although it is not needed? I need a Guid, so I canβt just get rid of it and replace it with an integer.
Any thoughts on best practices?
source share