title: 'Unable to resolve service for type ¨Microsoft.entityFrameworkCore.DbContextOptions¨1[LibraryData.LibraryContext] while attempting to activate
body: <p>I've run into a problem i cannot solve on my own, so I'm asking for help.</p>
  <p>I've recently began learning ASP .net core, and wanted to build a library where i have to have a database, login system and admin powers to be able to add and delete books from the website.</p>
  <p>I've created the login system and database, now i want to add the CRUD to the project, but this error pops up</p>
  <p>&quot;'Unable to resolve service for type ¨Microsoft.entityFrameworkCore.DbContextOptions¨1[LibraryData.LibraryContext] while attempting to activate &quot;LibraryData.LibraryContext&quot;</p>
  <p>This is my code so far...</p>
  <p>LibraryData.LibraryContext.cs</p>
  <pre><code>public class LibraryContext : DbContext
      {
          public LibraryContext(DbContextOptions&lt;LibraryContext&gt; options) : base(options)
          {
  
          }
  
          public DbSet&lt;User&gt; Users { get; set; }
          public DbSet&lt;Video&gt; Videos { get; set; }
          public DbSet&lt;BranchHours&gt; BranchHour { get; set; }
          public DbSet&lt;Checkout&gt; checkouts { get; set; }
          public DbSet&lt;CheckoutHistory&gt; checkoutHistorys { get; set; }
          public DbSet&lt;Holds&gt; holds { get; set; }
          public DbSet&lt;LibraryAsset&gt; LibraryAssets { get; set; }
          public DbSet&lt;Book&gt; Books { get; set; }
          public DbSet&lt;LibraryBranch&gt; libraryBranches { get; set; }
          public DbSet&lt;LibraryCard&gt; LibraryCards { get; set; }
          public DbSet&lt;Status&gt; statuses { get; set; }
      }
  </code></pre>
  <p>Startup.cs</p>
  <pre><code>        public IConfiguration Configuration { get; }       
          
          public Startup(IConfiguration configuration)
          {
              Configuration = configuration;
          }
  
          public void ConfigureServices(IServiceCollection services)
          {
              services.AddMvc();
              services.AddMvc().AddSessionStateTempDataProvider();
              services.AddDistributedMemoryCache();
              services.AddSession();
              services.AddSingleton(Configuration);
              services.AddScoped&lt;ILibraryAsset, LibraryAssetService&gt;();
              services.AddControllersWithViews();
              services.AddDbContext&lt;LibraryContext&gt;(options
                   =&gt; options.UseSqlServer(Configuration.GetConnectionString(&quot;LibraryConnection&quot;)));
              services.AddIdentity&lt;IdentityUser, IdentityRole&gt;().AddEntityFrameworkStores&lt;LibraryContext&gt;();
              services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie();
              services.AddScoped&lt;DbContext, LibraryContext&gt;();
              services.TryAddSingleton&lt;IHttpContextAccessor, HttpContextAccessor&gt;();
          }
  
                 public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
          {
              if (env.IsDevelopment())
              {
                  app.UseDeveloperExceptionPage();
              }
              else
              {
                  app.UseExceptionHandler(&quot;/Home/Error&quot;);
                  app.UseHsts();
              }
              app.UseHttpsRedirection();
              app.UseStaticFiles();
              app.UseSession();
              app.UseRouting();
              app.UseAuthorization();
  
              app.UseEndpoints(endpoints =&gt;
              {
                  endpoints.MapControllerRoute(
                      name: &quot;default&quot;,
                      pattern: &quot;{controller=Home}/{action=Index}/{id?}&quot;);
              });
          }
  </code></pre>
  <p>Program.cs</p>
  <pre><code>    public class Program
      {
          public static void Main(string[] args)
          {
              CreateHostBuilder(args).Build().Run();
          }
  
          public static IHostBuilder CreateHostBuilder(string[] args) =&gt;
              Host.CreateDefaultBuilder(args)
                  .ConfigureWebHostDefaults(webBuilder =&gt;
                  {
                      webBuilder.UseStartup&lt;Startup&gt;();
                  });
      }
  </code></pre>
  <p>AssetIndexListingModel.cs</p>
  <pre><code>    public class AssetIndexListingModel
      {
          public int Id { get; set; }
          public string ImageUrl { get; set; }
          public string Title { get; set; }
          public string AuthorOrDirector { get; set; }
          public string Type { get; set; }
          public string DeweyCallNumber { get; set; }
          public string NumberOfPages { get; set; }
          public int DateOfRealease { get; set; }
          public int AgeRes { get; set; }
          public string About { get; set; }
      }
  </code></pre>