I know that a very similar question was asked here, but the answer did not help me.
I am using Entity Framework 6 with Oracle.ManagerDataAccess.Client.
If I define the connection string in app.config, then the connection works. If I specify an identical connection string in the code, I will get an error
The value length for key 'data source' exceeds it limit of '128'.
what is right.
This is my connection string (with deleted names):
"User Id=xxxxxxxxxxx;Password=xxxx;Data Source=( DESCRIPTION = ( ADDRESS_LIST = ( ADDRESS = (PROTOCOL = TCP)(HOST = VS-ORACLE.xxxxxxx.de)(PORT = 1521) ) ) ( CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = orcl.xxxxxxxx.de) ) )"
I know there are a bunch of spaces that can be removed, but I still wonβt get a line below 128 characters.
How does this work when the connection string is in app.config, but not when it is in code?
Is there any trick I can use when unloading some parameters to another line?
DBConfiguration. ?
oracle, , tnsnames.ora, , .
app.config
<connectionStrings>
<add name="OracleDbContext" providerName="Oracle.ManagedDataAccess.Client" connectionString="User Id=xxxxxxxxxxx;Password=xxxx;Data Source=( DESCRIPTION = ( ADDRESS_LIST = ( ADDRESS = (PROTOCOL = TCP)(HOST = VS-ORACLE.xxxxxxxx.de)(PORT = 1521) ) ) ( CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = orcl.xxxxxxxx.de) ) )" />
</connectionStrings>
:
[DbConfigurationType(typeof(OracleDBConfiguration))]
public class GlobalAttributeContext : DbContext
{
public DbSet<GlobalAttribute> GlobalAttributes { get; set; }
static GlobalAttributeContext()
{
Database.SetInitializer<GlobalAttributeContext>(null);
}
public GlobalAttributeContext(string nameOrConnectionString) : base(nameOrConnectionString)
{
}
public GlobalAttributeContext() : this ( "Name=OracleDbContext" )
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Configurations.Add(new GlobalAttribute_Config_Oracle("SchemaName")) ;
}
}
DbConfiguration :
class OracleDBConfiguration : DbConfiguration
{
public OracleDBConfiguration()
{
this.SetDefaultConnectionFactory ( new System.Data.Entity.Infrastructure.LocalDbConnectionFactory("v12.0") ) ;
this.SetProviderServices ( "Oracle.ManagedDataAccess.Client", Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices.Instance ) ;
this.SetProviderFactory ( "Oracle.ManagedDataAccess.Client", Oracle.ManagedDataAccess.Client.OracleClientFactory.Instance ) ;
}
}
,
string ConnectionString = "User Id=xxxxxxxxxxx;Password=xxxx;Data Source=( DESCRIPTION = ( ADDRESS_LIST = ( ADDRESS = (PROTOCOL = TCP)(HOST = VS-ORACLE.xxxxxxxx.de)(PORT = 1521) ) ) ( CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = orcl.xxxxxxx.de) ) )" ;
using (var ctx = new GlobalAttributeContext(ConnectionString))
{
var globalAttributes = ctx.GlobalAttributes.ToList() ;
foreach ( GlobalAttribute ga in globalAttributes )
{
Console.WriteLine ( "Name: {0}, Value: {1}", ga.Attribute, ga.Value ) ;
}
}
, , .