Difference between FluentNHibernate and NHibernate’s “Mapping by Code”

Fluent NH Fluent NHibernate offers an alternative to NHibernate’s standard XML mapping files. Rather than writing XML documents, you write mappings in strongly typed C# code. This allows for easy refactoring, improved readability and more concise code. vs. NH’s new mapping by code It is an XML-less mapping solution being an integral part of NHibernate … Read more

Install NHibernate 3.2 with NuGet

NHibernate 3.2 comes with its own proxy factory. If you’re using a config file, you just need to remove the proxyfactory configuration property. I believe the version of Fluent NHibernate that you’re using defaults to use NHibernate.ByteCode.Castle. In that case, you would need to override that setting with the built in NHibernate 3.2 proxy factory: … Read more

How to configure fluent nHibernate with MySQL

Change MsSqlConfiguration.MsSql2005, to MySqlConfiguration.Standard, it was the one thing I contributed to the project. Example: Fluently.Configure().Database( MySqlConfiguration.Standard.ConnectionString( c => c.FromConnectionStringWithKey(“ConnectionString”) ) ) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<MyAutofacModule>()) .BuildSessionFactory())

What are the differences between HasOne and References in nhibernate?

HasOne creates a one-to-one mapping between tables for you. References creates a typical relational many-to-one relationship. More defined: a one-to-one relationship means that when one record exists in one table, it must (or can) have one and at most one record in the other referenced table. Example: User table and Options table (one user has … Read more

Fluent NHibernate – Create database schema only if not existing

You can just use SchemaUpdate instead, it will update the schema if it exists and create it if it does not: public NhibernateSessionFactory(IPersistenceConfigurer config) { _sessionFactory = Fluently.Configure(). Database(config). Mappings(m => m.FluentMappings.AddFromAssemblyOf<MappingsPersistenceModel>()). ExposeConfiguration(cfg => new SchemaUpdate(cfg).Execute(false, true)). BuildSessionFactory(); } One caveat: SchemaUpdate does not do destructive updates (dropping tables, columns, etc.). It will only add … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)