打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
netcore数据连接配置

第一种

appsettings.json

{

  "ConnectionStrings": {
    "DefaultConnection": "Server=localhost;database=typecho;uid=root;pwd=woshishui;"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*"
}

ConfigureServices

 services.AddDbContext<typechoContext>(options=>options.UseMySql(Configuration.GetConnectionString("DefaultConnection")));

第二种

ConfigureServices

      // other service configurations go here
            // replace "YourDbContext" with the class name of your DbContext
services.AddDbContextPool<typechoContext>(options => options
            //     // replace with your connection string          .UseMySql("Server=localhost;Database=typecho;User=root;Password=woshishui;", mySqlOptions => mySqlOptions
            //         // replace with your Server Version and Type
    .ServerVersion(new ServerVersion(new Version(8, 0, 19), ServerType.MySql))
            //     ));
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
解决ASP连接SQLServer不成功!
apache目录浏览设置
SQL Server 查询时 like 特殊字符转义
SQL Server日期格式的转换
sublimetext3
NFS Client 和 Server的缓存配置,即异步和同步IO
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服