Before this is marked as duplicate I have looked around to find an answer for my question, but my scenario is a little more specific than other similar questions found on SO and I don't think anwers like "it's a bad practice" apply.

I am working on some design choices for modeling the domain following the DDD approach with Entity Framework, and I am interested in a way to inject dependencies into Entities. To be precise the only dependencies I consider worth injecting are factories for domain objects that belong to the aggregate root I am working with or wrappers around static classes like the one below:

```
public class CurrentTimeProvider : ITimeProvider
{
    public DateTime GetTime()
    {
        return DateTime.Now();
    }
}

```

The purpose of the wrapper is to make unit testing easier and I am not a fan of the double dispatch pattern for this case as it breaks encapsulation.

Sample entity:

```
public class ActivationToken
{
    protected ITimeProvider TimeProvider;

    public ActivationToken(ITimeProvider timeProvider)
    {
        TimeProvider = timeProvider;
    }

    public virtual DateTime? ConsumedTime { get; protected set; }

    public virtual void Consume()
    {
        ConsumedTime = TimeProvider.GetTime();
    }
}

```

So my question is how do I get Entity Framework to provide my dependency when creating the instance?