title: Moq and setting up DB Context
body: <p>I have an Entity Framework DB Context file.
  I am trying to setup a Moq framework in NUnit. Currently receiving error below for Moq Nunit test. How would I setup the DBContext, and add items to a Product Table?</p>
  
  <p>"No database provider has been configured for this DbContext. A provider can be configured by overriding the DbContext.OnConfiguring method or by using AddDbContext on the application service provider. If AddDbContext is used, then also ensure that your DbContext type accepts a DbContextOptions object in its constructor and passes it to the base constructor for DbContext."</p>
  
  <p><strong>Electronics DB Context file</strong></p>
  
  <pre><code>public partial class ElectronicsContext : DbContext
  {
      public ElectronicsContext()
      {
      }
  
      public ElectronicsContext(DbContextOptions&lt;ElectronicsContext&gt; options)
          : base(options)
      {
      }
  
      public virtual DbSet&lt;Product&gt; Product { get; set; }
      public virtual DbSet&lt;ProductCategory&gt; ProductCategory { get; set; }
  </code></pre>
  
  <p><strong>Startup.cs</strong></p>
  
  <pre><code>    var connection = @"Server=localhost;Database=Electronics;Trusted_Connection=True;ConnectRetryCount=0";
      services.AddDbContext&lt;ElectronicsContext&gt;(options =&gt; options.UseSqlServer(connection));
  </code></pre>
  
  <p><strong>Moq Nunit Test</strong></p>
  
  <pre><code> [SetUp]
   public void Setup()
   {
      var ElectronicsContext = new Mock&lt;ElectronicsContext&gt;();
      var ProductRepository = new Mock&lt;ProductRepository&gt;();
  
      Product producttest = new Product();
      _dbContext.Product.Add(new Product {ProductId = 1, ProductName = "TV", ProductDescription = "TV testing",ImageLocation = "test"});
      _dbContext.SaveChanges();
  </code></pre>