私はEFコアを初めて使用し、それをASP.NETコアプロジェクトで使用できるようにしています。
configの接続文字列を使用するstartup.csようにDbContextを設定しようとすると、上記のエラーが発生します。私はこのチュートリアルに従っています:https : //docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/intro
の問題のあるコードstartup.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.SpaServices.Webpack;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.EntityFrameworkCore;
using tracV2.models;
using tracV2.data;
namespace tracV2
{
    public class Startup
    {
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddMvc();
            services.AddSingleton<IConfiguration>(Configuration);
            string conn = Configuration.GetConnectionString("optimumDB");
            services.AddDbContext<tracContext>(options => options.usesqlserver(conn));
        }
UseSqlServer私は、コンテキストに直接それを置く場合は方法が認識されています:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
namespace tracV2.data
{
    public class tracContext : DbContext
    {
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseSqlServer("myrealconnectionstring");
        }
私のすべてのオンライン調査では、欠落している参照が指摘されていますが、どれが欠落しているのかわかりません(画像を参照)。







