Where is the .AddDBContext method?

He said everywhere to call the services.AddDBContext <> method, but it is not recognized inside the ConfigureServices method (IServiceCollection services).
What am I doing wrong?

+4
source share
2 answers

First you need to specify the correct package, which depends on the EF Core provider that you want to use.

Microsoft.EntityFrameworkCore.SqlServerfor SQL Server, Microsoft.EntityFrameworkCore.Sqlitefor SQLite, and Microsoft.EntityFrameworkCore.InMemoryfor memory (for testing only).

These are official service providers. There are also third-party providers of PostgreSQL, MySQL, etc. Documentation providers provide a list of available third-party providers here .

, . Microsoft.Extension.DependencyInjection, using Microsoft.Extension.DependencyInjection; Startup.cs.

(, Oracle MySQL) MySQL.Data.EntityFrameworkCore.Extensions, using MySQL.Data.EntityFrameworkCore.Extensions;

+5

, using Microsoft.EntityFrameworkCore, . , , .

0

Source: https://habr.com/ru/post/1671464/


All Articles