I need help ! I'm not sure the title is significant enought so i will try to explain better.
I work on an angular web site that uses http requests to a ASP.NET web api site.
My database is an Oracle one.
I use Entity Framework ( Database First ) with an hardcoded connection string ( in my web.config )
<add name="UserConnection" connectionString="DATA SOURCE=ip:port/name;PASSWORD=pwd;PERSIST SECURITY INFO=True;USER ID=usr"
providerName="Oracle.ManagedDataAccess.Client" />
( I replaced real infos with ip;port;name;pwd;usr since I can't show them )
public partial class db: DbContext {
public db(string connectionString) : base(connectionString) {}
... }
"The supplied sqlconnection does not specify an initial catalog or attachdbfilename oracle"
public db(string connectionString) : base(new OracleConnection(connectionString)) {}
" Erreur CS1503 Argument 1 : conversion impossible de 'Oracle.ManagedDataAccess.Client.OracleConnection' en 'System.Data.Entity.Infrastructure.DbCompiledModel' "
You can set dynamically new OracleConnection
, but you need also set contextOwnsConnection
to true
. This resolve your error :
" Erreur CS1503 Argument 1 : conversion impossible de 'Oracle.ManagedDataAccess.Client.OracleConnection' en 'System.Data.Entity.Infrastructure.DbCompiledModel' "
public partial class Entities : DbContext
{
public Entities()
: base(new OracleConnection("DATA SOURCE=Server; PASSWORD=123;USER ID=SYSTEM"), true)
{
}
}