Official setting document: https://www.donet5.com/Doc/10/2251
Open Startup.cs to configure the following code
//注入 ORM
builder.Services.AddSqlSugar(new IocConfig()
{
ConnectionString = builder.Configuration.GetConnectionString("DbConnectionString"), //数据库连接串
DbType = IocDbType.MySql, //数据库类型
IsAutoCloseConnection = true//自动释放
});
Remember to configure the database connection string in appsettings.json
"ConnectionStrings": {
"DbConnectionString": "server=localhost;port=3306;Database=ningblog;Uid=root;Pwd=123456;SslMode=none"
},
Then we can use it on the page
**
DbScoped.Sugar 非线程安全
DbScoped.SugarScope 线程安全
**