1

I have downloaded the Fluent NHibernate source distribution, compiled all projects in solution and then run Examples.FirstProject. Exception occur in FluentConfiguration.cs in method BuildSessionFactory(): An invalid or incomplete configuration was used while creating a SessionFactory. What shall I do to avoid this exception?

PS I saw this post but its not help me

Edit: Exception Message "The following types may not be used as proxies:\nExamples.FirstProject.Entities.Employee: method set_Id should be 'public/protected virtual' or 'protected internal virtual'\nExamples.FirstProject.Entities.Product: method set_Id should be 'public/protected virtual' or 'protected internal virtual'\nExamples.FirstProject.Entities.Store: method set_Id should be 'public/protected virtual' or 'protected internal virtual'" string

Exception Source: "NHibernate"

Exception StackTrace: StackTrace " at NHibernate.Cfg.Configuration.ValidateEntities() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:line 1051\r\n at NHibernate.Cfg.Configuration.Validate() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:line 958\r\n at NHibernate.Cfg.Configuration.BuildSessionFactory() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:line 1250\r\n at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in C:\_WorkProjects\_nHibernate\jagregory-fluent-nhibernate-c24de5a\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 231" string

Community
  • 1
  • 1
Max Kilovatiy
  • 798
  • 1
  • 11
  • 32

2 Answers2

4

Go to (Examples.FirstProject -> Entities -> and in (Employee.cs, Product.cs, and Store.cs)

Change the Id property from:

public virtual int Id { get; private set; }

To:

public virtual int Id { get; set; }
Idrees
  • 711
  • 1
  • 7
  • 31
0

Your type, Examples.FirstProject.Entities.Employee should have the ID property set to

public virtual int ID { get; set; }
Pieter Germishuys
  • 4,828
  • 1
  • 26
  • 34
  • @Windman Did you make ALL properties of ALL mapped entities virtual? – Jonas Høgh Aug 17 '11 at 13:08
  • I've downloaded wrong source files from https://github.com/jagregory/fluent-nhibernate (just click Download button) When I get it from official site http://fluentnhibernate.org/ (only dll files) and add to my project everything works fine! – Max Kilovatiy Aug 17 '11 at 15:31