Questions tagged [fluent-nhibernate]

Fluent NHibernate lets you write NHibernate mappings in strongly typed C# code. This allows for easy refactoring, improved readability and more concise code.

Fluent NHibernate offers an alternative to NHibernate's standard XML mapping files. Rather than writing XML documents (.hbm.xml files), Fluent NHibernate lets you write mappings in strongly typed C# code. This allows for easy refactoring, improved readability and more concise code.

Installation Fluent NHibernate can most easily be installed through its NuGet package.

Install-Package FluentNHibernate

Resources

5486 questions
10
votes
5 answers

Generate C# entities from existing DB and Fluent NHibernate auto mapping

I'm working with an existing database that uses some really ugly conventions. I'd like to use NHibernate, and I think I can fix all these ugly DB conventions using Fluent NHibernate's auto mapping conventions. I'd like to avoid writing all the…
Lance Fisher
  • 25,684
  • 22
  • 96
  • 122
10
votes
3 answers

Does Fluent-Hibernate exist?

Is there something like Fluent-NHibernate for the original Java Hibernate? If not, why not? Are there any language-specific limitations?
Marc Wittke
  • 2,991
  • 2
  • 30
  • 45
10
votes
3 answers

Ignoring methods on entity types with nHibernate

I've got a class something like this: public class Account { public virtual int Id { get; private set; } public virtual string Username { get; set; } [EditorBrowsable( EditorBrowsableState.Never )] public virtual string Password {…
Paul Alexander
  • 31,970
  • 14
  • 96
  • 151
10
votes
3 answers

Fluent NHibernate One-To-Many Mapping

I have the following 2 classes: Advert public virtual int Id { get; set; public virtual IList AdvertImages { get; set; } AdvertImage public virtual int Id { get; set; } public virtual string Filename { get; set; public virtual Advert…
10
votes
1 answer

Error with hilo in NHibernate - "could not read a hi value - you need to populate the table"

I've genereated a schema for my (SQL 2005) db using SchemaExport, and it's created a table CREATE TABLE [dbo].[hibernate_unique_key]( [next_hi] [int] NULL ) ON [PRIMARY] When I try to add an entity, I get the error "could not read a hi value -…
mcintyre321
  • 12,996
  • 8
  • 66
  • 103
9
votes
1 answer

Mapping to multiple tables with Fluent nHibernate

Here's my situation.. Suppose you have the following model entities, which represent single tables on their own: Movies [ Movie_Id, Title, Rating, .. ] Actors [ Actor_Id, FirstName, LastName, .. ] Director [ Director_Id, FirstName, LastName, ..…
Matias Bello
  • 93
  • 1
  • 4
9
votes
4 answers

Fluent NHibernate - Map 2 tables to one class

I have a table structure something like this table Employees EmployeeID EmployeeLogin EmployeeCustID table Customers CustomerID CustomerName What i would like is to map the structure above to one single class named: Class Employee …
Morten Schmidt
  • 642
  • 8
  • 22
9
votes
1 answer

How does one gracefully merge object graphs after NHibernate StaleObjectStateException?

We are trying to combine objects after a StaleObjectStateException has been thrown to save a merged copy. Here's our environmental situation: List item Multi-user system WPF Desktop application, SQL Server 2008 database NHibernate 3.1.0.4000,…
9
votes
6 answers

NHibernate - LAZY LOADING PROBLEM -Initializing[]-Could not initialize proxy - no Session."}

Hi I use Fluent NHibernate and I am little confusing with Lazy Loading. I queried object in database modified object properties update database with this object Here is code: public class Credentials { public virtual int Id { get; set; } …
user572844
9
votes
1 answer

No session bound to the current context

I followed this tutorial: http://nhforge.org/blogs/nhibernate/archive/2011/03/03/effective-nhibernate-session-management-for-web-apps.aspx I am not getting a 'no session bound to the current context' error when trying to load a page (mvc 3). public…
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
9
votes
1 answer

Fluent NHibernate 3 uniquekey custom constraint name

I am trying to give a custom Unique Constraint Name as follows: Map(x => x.Name).UniqueKey("MY_CONSTRAINT_NAME").Column("FUNCTION_NAME"); The Field is mapped with a unique constraint but the constraint name is self-managed and doesn't take the name…
user756037
  • 285
  • 1
  • 8
  • 20
9
votes
3 answers

Fluent NHibernate HasMany Foreign Key Mapping Problem

I'm trying to map a simple data structure in nhibernate Tables: Employees employeeID int username varchar(30) departmentID int Departments departmentID int deptName varchar(50) My department mapping is like so: public class DepartmentMap:…
Chris Klepeis
  • 9,783
  • 16
  • 83
  • 149
9
votes
3 answers

Mapping the same entity to different tables

A bit of domain knowledge I'm writing a POS (Point Of Sales) software which allows to pay goods or to refund them. When paying or refunding, one need to specify which money transfer mean to use: cash, EFT (~=credit card), loyalty card, voucher,…
9
votes
2 answers

Path Expected for Join! Nhibernate Error

I trying to do a join and I keep getting this error Path expected for join! [SELECT t.CourseId FROM Task as t INNER JOIN Courses as c, CoursePermissions as cp WHERE (t.CourseId = 1)] I have const string query = "SELECT t.CourseId FROM Task…
chobo2
  • 83,322
  • 195
  • 530
  • 832
9
votes
2 answers

Fluent NHibernate - how to configure for oracle?

Almost certainly a stupid question but I can't find the answer anywhere. In the Getting Started tutorial the database is SQLite and so his session factory creation is done using the SQLiteConfiguration class in the FluentNHibernate.Cfg.Db…
George Mauer
  • 117,483
  • 131
  • 382
  • 612