title: Entity Framework Core single object instead of List
body: <p>I have a question. Is it possible to force Entity Framework to make one instance of class instead of (for example) <code>IEnumerable</code>? </p>
  
  <p>In my database, i want to have only one <code>Farm</code> instead of <code>Farms</code>. My <code>Farm</code> have all other List in it that i mentioned in my DBContext:</p>
  
  <pre><code>public class FarmDbContext : DbContext
  {
      public FarmDbContext(DbContextOptions&lt;FarmDbContext&gt; options) : base(options) { }
  
      public DbSet&lt;Farm&gt; Farms { get; set; } //i want to have one instance of farm
      public DbSet&lt;Machine&gt; Machines { get; set; }
      public DbSet&lt;Stable&gt; Stables { get; set; }
      public DbSet&lt;Worker&gt; Workers { get; set; }
      public DbSet&lt;Cultivation&gt; Cultivations { get; set; }
  }
  </code></pre>
  
  <p>And my Farm class, that is a <a href="https://en.wikipedia.org/wiki/Singleton_pattern" rel="nofollow noreferrer">Singleton</a> (class with private constructor only with <code>GetInstance()</code> method):</p>
  
  <pre><code>public class Farm
  {
      [Key]
      public int Id { get; set; }
      public string Name { get; set; }
  
      public virtual List&lt;Stable&gt; Stables { get; set; }
      public virtual List&lt;Machine&gt; Machines { get; set; }
      public virtual List&lt;Worker&gt; Workers { get; set; }
      public virtual List&lt;Cultivation&gt; Cultivations { get; set; }
  
      public Farm GetFarm() =&gt; farm;
  
      private Farm farm;
      private Farm() { }
  }
  </code></pre>
  
  <p>So how to make one <code>Farm</code> in whole database in Code First EntityFramework Core?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Maybe i wont 100% accurate with my question. </p>
  
  <p>How to get single instance of Farm every time, i call a context? For example, i have a <code>GET</code> function:</p>
  
  <pre><code>private readonly FarmDbContext _context;
  public FarmController(FarmDbContext context) =&gt; _context = context;
  
  
  // GET: api/Farm
  [HttpGet]
  public IActionResult GetFarms() =&gt; Ok(_context.Farms.SingleOrDefault());
  </code></pre>
  
  <p>Can i call my <code>Farm.GetFarm() =&gt; this.farm</code> from <code>DBContext</code>?</p>