title: Migrations is enabled for context ''but the database does not exist or contains no mapped tables
body: <h2>CreditoImobiliarioBB.Web</h2>
  
  <p>All interface are defined here. Has reference to the project <code>CreditoImobiliarioBB.EntityFramework</code> and EF6.<br>
  <strong>No</strong> configuration (we use FluentApi) or migrations is defined here.</p>
  
  <h2>CreditoImobiliarioBB.EntityFramework</h2>
  
  <p>Here is defined our generic repository and DbContext. All configurations and <strong>migrations are implemented here</strong>.</p>
  
  <h2>CreditoImobiliarioBB.Domain</h2>
  
  <p>Our design domain. Here are all our domain classes and interfaces (eg <code>IEntity</code>)</p>
  
  <h2>CreditoImobiliarioBB.Repository</h2>
  
  <p>Here is the repository implementation. For example <code>EmployeesRepository</code></p>
  
  <h1>Error</h1>
  
  <p>When we run our application, the following error occurs:</p>
  
  <blockquote>
    <p>Migrations is enabled for context 'CreditoImobiliarioContext' but the database does not exist or contains no mapped tables. Use Migrations to create the database and its tables, for example by running the 'Update-Database' command from the Package Manager Console.</p>
  </blockquote>
  
  <h1>Considerations</h1>
  
  <ol>
  <li><p>The database has been created with all configurations aka <code>EntityTypeConfiguration&lt;&gt;</code> via the 'Update-Database'</p></li>
  <li><p>The error occurs in <code>CreditoImobiliarioBB.EntityFramework</code> project in a generic class <code>Repository</code></p></li>
  </ol>
  
  <h2>Repository.cs</h2>
  
  <p>Error in line <code>return _unitOfWork.Context.Set&lt;T&gt;().Where(expression);</code></p>
  
  <pre><code>public abstract class Repository&lt;T&gt; : IRepository&lt;T&gt;
          where T : class, IEntity
  {
      private readonly EFUnitOfWork _unitOfWork;
      public Repository(IUnitOfWork unitOfWork)
      {
          _unitOfWork = (EFUnitOfWork)unitOfWork;
      }
  
      public void Delete(T obj)
      {
          _unitOfWork.Context.Set&lt;T&gt;().Remove(obj);
      }
  
      public void Store(T obj)
      {
          if (_unitOfWork.Context.Entry(obj).State == System.Data.Entity.EntityState.Modified)
              _unitOfWork.Context.Set&lt;T&gt;().Attach(obj);
          else
              _unitOfWork.Context.Set&lt;T&gt;().Add(obj);
      }
  
      public IQueryable&lt;T&gt; All()
      {
          return _unitOfWork.Context.Set&lt;T&gt;();
      }
  
      public object Get(Type entity, int id)
      {
          return _unitOfWork.Context.Set(entity).Find(id);
      }
  
      public T Get(Expression&lt;Func&lt;T, bool&gt;&gt; expression)
      {
          return _unitOfWork.Context.Set&lt;T&gt;().SingleOrDefault(expression);
      }
  
      public T Get(int id)
      {
          return _unitOfWork.Context.Set&lt;T&gt;().Find(id);
      }
  
      public IQueryable&lt;T&gt; Query(Expression&lt;Func&lt;T, bool&gt;&gt; expression)
      {
          return _unitOfWork.Context.Set&lt;T&gt;().Where(expression);
      }
  
      public IUnitOfWork UnitOfWork
      {
          get { return _unitOfWork; }
      }
  }
  </code></pre>