NetCore-EF基本代码片段

1.数据连接

(1)连接字符串在Startup.cs中

services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
var connection = @"Server=.;Database=Blogging;Trusted_Connection=True;ConnectRetryCount=0";
services.AddDbContext<BloggingContext>(options => options.UseSqlServer(connection));

(2)连接字符串在appsettings.json中

猜你喜欢

转载自www.cnblogs.com/dxh0535/p/9346950.html
今日推荐