c# - Unable to cast object of type 'Oracle.DataAccess.Client.OracleConnection' to type 'System.Data.Common.DbConnection' -
i trying setup nhibernate first time , struggling! using oracle database , have following
app.config:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configsections> <section name="hibernate-configuration" type="nhibernate.cfg.configurationsectionhandler, nhibernate"/> </configsections> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> <session-factory> <property name="connection.provider"> nhibernate.connection.driverconnectionprovider </property> <property name="dialect"> nhibernate.dialect.oracle10gdialect </property> <property name="connection.driver_class"> nhibernate.driver.oracledataclientdriver </property> <property name="connection.connection_string"> data source=ctir;persist security info=true;user id=****;password=*****; </property> <property name="show_sql"> true </property> </session-factory> </hibernate-configuration> </configuration> and following form1.cs:
namespace testnhibernate { public partial class form1 : form { private configuration myconfig; private isessionfactory mysessionfactory; private isession mysession; public form1() { initializecomponent(); } private void form1_load(object sender, eventargs e) { myconfig = new configuration(); myconfig.configure(); schemametadataupdater.quotetableandcolumns(myconfig); <-- here execption mysessionfactory = myconfig.buildsessionfactory(); mysession = mysessionfactory.opensession(); using (mysession.begintransaction()) { agenter agent = new agenter {fornavn = "marc", initialer = "mrcr212", id = 999, efternavn = "rasmussen" }; mysession.save(agent); mysession.transaction.commit(); } } } when run in debug mode following error:
unable cast object of type 'oracle.dataaccess.client.oracleconnection' type 'system.data.common.dbconnection'. can tell me im doing wrong?
** update**
according question: stack question
i should add following line:
<property name="hbm2ddl.keywords">none</property> however did not solve issue
Comments
Post a Comment