c# - Facing issue in connecting oracle with entity frameowrk -


i using oracle 11g , entity framework 6 versions.

i facing following error:

"an error occurred while getting provider information database. can caused entity framework using incorrect connection string. check inner exceptions details , ensure connection string correct."

my app.config follows:

<?xml version="1.0" encoding="utf-8"?> <configuration>   <configsections>     <!-- more information on entity framework configuration, visit http://go.microsoft.com/fwlink/?linkid=237468 -->     <section name="entityframework"       type="system.data.entity.internal.configfile.entityframeworksection, entityframework, version=6.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089" requirepermission="false"/>      <section name="oracle.manageddataaccess.client"       type="oracleinternal.common.odpmsectionhandler, oracle.manageddataaccess, version=4.121.2.0, culture=neutral, publickeytoken=89b483f429c47342"/>   </configsections>   <startup>     <supportedruntime version="v4.0" sku=".netframework,version=v4.5"/>   </startup>   <connectionstrings>     <clear/>      <add name="oracledbcontext" providername="oracle.manageddataaccess.client"        connectionstring=" data source=hrfolatest1;user id=hrms2;password=hrms2;"/>    </connectionstrings>   <entityframework>      <defaultconnectionfactory type="system.data.entity.infrastructure.sqlconnectionfactory, entityframework"/>      <providers>       <provider invariantname="system.data.sqlclient" type="system.data.entity.sqlserver.sqlproviderservices, entityframework.sqlserver"/>        <provider invariantname="oracle.manageddataaccess.client"         type="oracle.manageddataaccess.entityframework.eforacleproviderservices, oracle.manageddataaccess.entityframework, version=6.121.2.0, culture=neutral, publickeytoken=89b483f429c47342"/>      </providers>    </entityframework>    <system.data>      <dbproviderfactories>        <remove invariant="oracle.manageddataaccess.client"/>        <add name="odp.net, managed driver" invariant="oracle.manageddataaccess.client" description="oracle data provider .net, managed driver"          type="oracle.manageddataaccess.client.oracleclientfactory, oracle.manageddataaccess, version=4.121.2.0, culture=neutral, publickeytoken=89b483f429c47342"/>      </dbproviderfactories>    </system.data>    <runtime>      <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">        <dependentassembly>          <publisherpolicy apply="no"/>          <assemblyidentity name="oracle.manageddataaccess" publickeytoken="89b483f429c47342" culture="neutral"/>          <bindingredirect oldversion="4.121.0.0 - 4.65535.65535.65535" newversion="4.121.2.0"/>        </dependentassembly>      </assemblybinding>    </runtime>  </configuration> 

my db context:

class databasecontext : dbcontext

{     public databasecontext() : base("oracledbcontext")     {      }     public dbset<user> users { get; set; }      protected override void onmodelcreating(dbmodelbuilder modelbuilder)     {         //configure domain classes using modelbuilder here          modelbuilder.entity<user>().totable("hrms_olas_tree");          modelbuilder.entity<user>().property(user => user.id).hascolumnname("emp_id").hascolumntype("varchar");          modelbuilder.entity<user>().property(user => user.name).hascolumnname("emp_name").hascolumntype("varchar");          base.onmodelcreating(modelbuilder);      } }  internal class user {     public long id { get; set; }     public string name { get; set; }  } 

please let me mistake doing.

i have changed connection string following , started working:

<add name="oracledbcontext" providername="oracle.manageddataaccess.client"       connectionstring=" data source=(description=(address=(protocol=tcp)(host=yourhostname)(port=yourportnumber))(connect_data=(service_name=""servicename))); user id=xxx;password=xxxx;"/> 

we can find these details in tnsnames.ora file.

in db context add following code:

protected override void onmodelcreating(dbmodelbuilder modelbuilder)          {             base.onmodelcreating(modelbuilder);              modelbuilder.hasdefaultschema("yourschemaname");              modelbuilder.configurations.add(new employeemapper());          } 

Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -