• .NETCore3.0 + EFCore中使用Oracle报“ORA-12154: TNS:could not resolve the connect identifier specified"的错误处理


    在.NETCore3.0 + EFCore中的Oracle连接串的Data Source如果直接用TNS NAME会报“ORA-12154: TNS:could not resolve the connect identifier specified”

    //eg:

    optionsBuilder.UseOracle(@"User Id=<USER>;Password=<PASSWORD>;Data Source=<TNS NAME>") ;
    假设上述TNS NAME=ORCL

    //解决办法是上面代码前追加:
    方案1:直接设置TnsAdmin路径

    // Set TnsAdmin value to directory location of tnsnames.ora and sqlnet.ora files
    OracleConfiguration.TnsAdmin = @"<DIRECTORY LOCATION>";


    方案2:单独设置Tns Name(两种方式)

    // Add data source through Add method on OracleDataSourceCollection
    OracleConfiguration.OracleDataSources.Add("ORCL", "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=<hostname>)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=<service name>)(SERVER=dedicated)))");

    // Add data source through indexer method on OracleDataSourceCollection
    OracleConfiguration.OracleDataSources["ORCL"] = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=<hostname>)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=<service name>)(SERVER=dedicated)))";

  • 相关阅读:
    让CEF支持FLASH(非安装插件的形式)
    解决SQLServer 2008 日志无法收缩,收缩后大小不改变
    HTML Socket实现 .NET
    JS基础之BOM对象
    JavaScript对象
    JS函数
    JavaScript概述
    CSS块级元素和行内元素
    返回顶部示例
    CSS属性操作二
  • 原文地址:https://www.cnblogs.com/fery/p/12441074.html
Copyright © 2020-2023  润新知