Error ORA-12154: could not resolve the connect identifier specified, in FluentNHibernate configuration

1

Download a solution that is already in production environment, from the server to my pc. However, executing it shows me an error of type FluentNHibernate.Cfg.FluentConfigurationException:

{"An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.\r\n\r\n"}

An InnerException with:

{"ORA-12154: TNS:could not resolve the connect identifier specified\n"}

And an error trace like this:

en FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
en PROYECTO_DATOS.SessionFactorySingleton.BuildSessionFactory(IPersistenceConfigurer configurer) en c:\PROYECTO\PROYECTO_DATOS\db\SessionFactorySingleton.cs:línea 88
en PROYECTO_DATOS.SessionFactorySingleton.StartSessionFactoryHash() en c:\PROYECTO\PROYECTO_DATOS\db\SessionFactorySingleton.cs:línea 67
en PROYECTO_DATOS.SessionFactorySingleton..ctor() en c:\PROYECTO\PROYECTO_DATOS\db\SessionFactorySingleton.cs:línea 34
en PROYECTO_DATOS.SessionFactorySingleton.Init() en c:\PROYECTO\PROYECTO_DATOS\db\SessionFactorySingleton.cs:línea 39
en PROYECTO.Global.Application_Start(Object sender, EventArgs e) en c:\PROYECTO\Global.asax.cs:línea 11

The configuration of the oracle is made with FluentNHibernate, as shown:

class ConfigOracle
{
    public string Key { get; set; }
    public string ConnectionString { get; set; }
    public IPersistenceConfigurer Configurar { get; set; }

    public ConfigOracle(string key, string connectionString)
    {
        Key = key;
        ConnectionString = connectionString;
        Configurar = OracleClientConfiguration.Oracle10.ConnectionString(ConnectionString).Driver<OracleClientDriver>().ShowSql();

    }
}

The error is presented in this part of my code, after debugging the table mapping code.

private ISessionFactory BuildSessionFactory(IPersistenceConfigurer configurer)
    {
        var config =
            Fluently.Configure()
                    .Database(configurer)
                    .Mappings(x =>
                    {
                        x.FluentMappings.AddFromAssemblyOf<clase1Map>();
                        x.HbmMappings.AddFromAssemblyOf<casle2Map>();
                    });

        return config.BuildSessionFactory(); <--- La ejecución se detiene aquí
    }

It seems to me that the problem is that it does not find the tns_name.ora of my machine to achieve the connection.

Try adding the environment variable TNS_ADMIN with the path of tnsname.ora but it did not work.

    
asked by Henry Caballero 12.09.2016 в 23:09
source

1 answer

1

The problem is solved. The application connects to several databases so I started to compare the connection chains that are defined in the application against those that are defined in the tns_name.ora of my pc strong> and what was missing was to define one of them in the tns_name.ora .

    
answered by 13.09.2016 в 23:08