1、appsettings.json增加連結
"ConnectionStrings": {
"Conn": "Data Source=.;Initial Catalog=FinanceInfo;Integrated Security=True;user id =sa;password=71720328;database=FinanceInfo;"
}
2、引入ef相關
3、建立類和上下文,例如FinanceInfoContext和employee類
4、注入服務
builder.Services.AddSqlServer<FinanceInfoContext>(builder.Configuration.GetConnectionString("Conn"));
5、顯示