1
votes

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

2
I don't know the tutorial project in question, but this exception can have a lot of different root causes. Usually a better error description is available in the InnerException - Jonas Høgh
You need to post the full exception and we can go from there. Use Exception.ToString() and post that here. - Cole W
Jonas H, what is "InnerException"? Fields of exception instance? - Max Kilovatiy
Also when you posting question about mapping an entity it helps to peps if you add entity and your mapping as code :) so you know - cpoDesign
@cpoDesign Thanks I do so next time - Max Kilovatiy

2 Answers

4
votes

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; }
0
votes

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

public virtual int ID { get; set; }