title: Dependency Injection into Entity Class
body: <p>Using Asp.Net Core we can make use of Dependency Injection in controllers/repositories.</p>
  
  <p>However, I wish do do some logging in my Entity Class.</p>
  
  <pre><code>class Person
  {
      private ILogger&lt;Person&gt; _logger;
      private List&lt;Pets&gt; pets;
  
      public Person(ILogger&lt;Person&gt; logger)
      {
          _logger = logger;
      }
  
      public bool HasCat()
      {
          _logger.LogTrace("Checking to see if person has a cat.");
          // logic to determine cat ownership
          hasCat = true;
          return hasCat;
      }
  }
  </code></pre>
  
  <p>When the Person class is instantiated by EntityFramework it does not attempt to inject any dependencies.</p>
  
  <p>Can I force this? Am i going about it in completely the wrong way?</p>
  
  <p>Ultimatley I just want to be able to use logging consistently throughout the application.</p>
  
  <p>Thanks,</p>