asp.net core 3.1 读取配置文件
配置文件:appsettings.json
{
"ConnectionStrings": {
"Contr": "Data Source=.;Initial Catalog=UData;User ID=sa; Password=pw; Max Pool Size = 512;Min Pool Size=10;Pooling=true"
}
}
连接信息类
public class CML_ConData
{
public string Contr{ get; set; }
}
Startup.cs里
public void ConfigureServices(IServiceCollection services)
{
var datacon = Configuration.GetSection("ConnectionStrings").Get<CML_ConData>();
//datacon .Contr
}