I have the following domain models:
public class User
{
public int Id { get; set; }
public ICollection<Product> Products { get; set; }
}
public class Product
{
public int Id { get; set; }
public decimal Price { get; set; }
}
My User entity has a collection of Products, and no Product can be created without an User. I am using EntityFramework Code First approach, which requires me to declare the Foreign Key on my Product entity, thus changing it to:
public class Product
{
public int Id { get; set; }
public decimal Price { get; set; }
public int UserId { get; set; }
}
I dont quite like this because, from the domain point of view, it is not interesting to have the User foreign key shown in my Product entity. This, however, does not bring any harm to me and I can live with it. Please, mind that I am using an ORM to simplify my work, so I am okay with it to an extent.
Is it okay to my domain entities having properties or such things only to satisfy my ORM of choice requirements?