0
这里我设置从Anguar2一些DB连接到数据库,但是当我尝试打数据库我收到提示为Additional information: No database provider has been configured for this DbContext. A provider can be configured by overriding the DbContext.OnConfiguring method or by using AddDbContext on the
如何从Asp.netcore Access数据库通过使用Entityfrmework
这是我的数据库连接
{
"connectionStrings": {
"DefaultConnection": "Server=MD;Database=Md;userid=sa;password=123;Trusted_Connection=True;MultipleActiveResultSets=true;"
}
startUp.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<StudentContext>(option => option.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddMvc();
}
DbContext.cs
public class StudentContext:DbContext
{
public StudentContext(DbContextOptions<StudentContext> options) : base(options) { }
public StudentContext() { }
public DbSet<StudentMaster> StudentMaster { get; set; }
}
appsetting.json,因为我在这个文件ü可以PLZ编写符合我这是R8或错误配置 –