title: adding records to inmemorydatabase just once
body: <p>I am trying to write my very first xunit test with Database, instead of mocking the DbContext I used the inMemoryDatabase as I read in articles, so I did like following</p>
  <p>public class GetCustomersTest
  {
  DbContextOptions _context;</p>
  <pre><code>    public GetCustomersTest()
      {
          if (_context==null)
              _context = CreateContextForCustomer();
      }        
      
      [Theory]
      [InlineData(1)]
      [InlineData(2)]
      public void GetCustomerById_ShouldReturnCorrectObject(int id)
      {
          using (var context = new DataBaseContext(_context))
          {
              var customerByIdService = new GetCustomerByIdService(context);
              
              var customer = customerByIdService.Execute(id);
              var customerActual = context.Customers.Where(x =&gt; x.Id == id).SingleOrDefault();
              var customerTmp = new Customer()
              {
                  Id = id,
                  FirstName = customer.Data.FirstName,
                  LastName = customer.Data.LastName,
                  Phone = customer.Data.Phone,
                  ClientNote = customer.Data.ClientNote
              };
              Assert.Equal(customerTmp.FirstName, customerActual.FirstName);
              Assert.Equal(customerTmp.LastName, customerActual.LastName);
              Assert.Equal(customerTmp.Phone, customerActual.Phone);
              Assert.Equal(customerTmp.ClientNote, customerActual.ClientNote);
  
          }
      }
  
      private DbContextOptions&lt;DataBaseContext&gt; CreateContextForCustomer() {
  
          var options = new DbContextOptionsBuilder&lt;DataBaseContext&gt;()
              .UseInMemoryDatabase(databaseName: &quot;SalonDatabase&quot;)
              .Options;
  
          using (var context = new DataBaseContext(options))
          {
              context.Customers.Add(new Customer
              {
                  Id = 1,
                  FirstName = &quot;User1&quot;,
                  LastName = &quot;Surname1&quot;,
                  Phone = &quot;123&quot;,
                  ClientNote = &quot;&quot;
              });
              context.Customers.Add(new Customer
              {
                  Id = 2,
                  FirstName = &quot;User2&quot;,
                  LastName = &quot;Surname2&quot;,
                  Phone = &quot;4567&quot;,
                  ClientNote = &quot;The best&quot;
              });
              
              context.SaveChanges();
          }
          return options;
      }
  }
  </code></pre>
  <p>it works find on [InlineData(1)] but when it comes to [InlineData(2)], it seems that it starts to run the constructor again , so as it wants to add the customerdata to table, it says that the record with that Id key exists.what is the best way for doing that?</p>