I have a Domain Library with a User Class. This class should not have any dependencies.
public abstract class UserEntity
{
public virtual string Id { get; set; } = string.Empty;
public string FirstName { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty;
}
In my Infrastructure Library (seperate project), I have a User Dto Class that inherits from “UserEntity”. This library has the MongoDB Drivers.
public class UserDto : UserEntity
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public override string Id { get; set; } = string.Empty;
}
What I’m trying to do is to make the “Id” property to be the Id for the Bson Object. I’m using Class inheritance to avoid mapping if possible. It was setup in this matter so I could use another Class Object that inherits “UserEntity” if I wanted to support another database.
The error message is below. What am I doing wrong or what can I do to get around this?