【发布时间】:2018-12-17 18:38:19
【问题描述】:
我正在开发一个不使用 Entity Framework 的 .NET Core 2.1 应用程序。但我想知道如何将连接字符串读入配置,因为通常的方法需要一个 DBContext 文件(我没有,因为我注意到使用 EF)。
如果我使用的是 EF,我通常会像这样从 appsettings.json 读取连接字符串:
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
没有 DBContext 怎么办?
【问题讨论】:
-
@KirkLarkin - System.Data.SqlClient。我已经编写了自己的数据访问类
标签: asp.net-core