NET CORE配置EF连接字符串。windows验证的连接字符串配置
电脑版发表于:2019/2/14 11:09
在appsettings.json中配置好连接字符串
{ "ConnectionStrings": { "BloggingDatabase": "Server=(localdb)\\mssqllocaldb;Database=EFGetStarted.ConsoleApp.NewDb;Trusted_Connection=True;" }, }
连接字符串提供用户名密码的方式
Server=66.66.66.66;UserId=SA;PWD=123456;Database=PERSON
方法2:
data source=.;initial catalog=modelfirst;user id=sa;password=123456;
从appsettings.json中读取配置的连接字符串
//从appsettings.json中读取配置的连接字符串 var connection = Configuration.GetConnectionString("BloggingDatabase");
官方文档:
https://docs.microsoft.com/zh-cn/ef/core/miscellaneous/connection-strings