A
A
Alexxxey_enot2021-03-14 22:12:15
ASP.NET
Alexxxey_enot, 2021-03-14 22:12:15

Problem in C# code "does not contain a definition of UseSqlServer and could not find an available extension method" how to solve it?

What needs to be connected is not clear

public class AppDBContent : DbContext
    {
        public AppDBContent(DbContextOptions<AppDBContent> options) : base(options)
        {

        }
        public Microsoft.EntityFrameworkCore.DbSet<Realty> Realty { get; set; }
        public Microsoft.EntityFrameworkCore.DbSet<Category> Category { get; set; }
    }

public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext<AppDBContent>(options => options.UseSqlServer(_confSting.GetConnectionString("DefaultConnection")));
            services.AddTransient<IAllRealty, MockRealty>();
            services.AddTransient<IRealtyCategory, MockCategory>();
            services.AddControllersWithViews();
            services.AddMvc();
        }
604e60036ad71863188247.png
604e600db5bd9694456449.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Django Almighty, 2021-03-15
@Alexxxey_enot

Open the NuGet Package Manager. Remove all existing packages related to Entity Framework and SQL.
Then install only one Microsoft.EntityFraneworkCore.SqlServer package.

K
KoreanGuy, 2021-03-14
@KoreanGuy

Apparently Microsoft.EntityFrameworkCore.SqlServer was not added

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question