1.
2.选择数据库与表
3.参数设定
4.把连接字符串放到脚本里面
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder){string conStr = ConfigurationManager.ConnectionStrings["Context"].ConnectionString;optionsBuilder.UseSqlServer(conStr);}
2.增加APP.config
3.增加连接字符串//;TrustServerCertificate=true一定要加上这个不然会报错‘证书链是由不受信任的颁发机构颁发的’<connectionStrings><add name="Context" connectionString="data source=dgfty\proddb;initial catalog=Kyla;persist security info=True;user id=ProdBarcodeSvc;password=sen7#an7;MultipleActiveResultSets=True;TrustServerCertificate=true" /></connectionStrings>