Olá pessoal, estou fazendo o curso de NHibernate pelo Alura, porém não gostaria de usar o MySQL e sim o MS SQLServer gostaria de saber como configurar.
Muito Obrigado galera!
Nhibernate puro ?
Se for FluentNhibernate
seria assim basicamente:
ISessionFactory sessionFactory = Fluently.Configure()
.Database(
MsSqlConfiguration.MsSql2012.ConnectionString(c => c.FromConnectionStringWithKey("ConnSQLServer")))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Models.Itens>())
.BuildSessionFactory();
ISession session = sessionFactory.OpenSession();
Tem algum código proposto pela curso?
Obrigado pelo retorno Dragoon segue o código proposto pelo curso:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration
xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">
NHibernate.Connection.DriverConnectionProvider
</property>
<property name="dialect">
NHibernate.Dialect.MySQL5Dialect
</property>
<property name="connection.driver_class">
NHibernate.Driver.MySqlDataDriver
</property>
<property name="connection.connection_string">
Server=localhost;Database=loja; Uid=nhibernate; Pwd=caelum;
</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>
Tentei usar assim mas não obtive sucesso:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory,NHibernate.ByteCode.Castle</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string">Data Source=desktop-th74pup\sqlexpress;Initial Catalog=LojaComNHibernate;User ID=sa;Password=123456</property>
<property name="dialect">NHibernate.Dialect.MsSql2014Dialect</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>
Tem que mudar o dialect
, driver_class
e a connection_string
, acredito que isso já resolva!
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration
xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">
NHibernate.Connection.DriverConnectionProvider
</property>
<property name="dialect">
NHibernate.Dialect.MsSql2012Dialect
</property>
<property name="connection.driver_class">
NHibernate.Driver.SqlClientDriver
</property>
<property name="connection.connection_string">
Server=.\SQLExpress;Database=Tests;User Id=sa;Password=senha;
</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>
Configure a connection_string
com as configurações do seu servidor!
1 curtida
Isso mesmo, vlw Dragoon!!!
1 curtida