我已经下载了Fluent NHibernate源代码分发,在解决方案中编译了所有项目,然后运行Examples.FirstProject。方法BuildSessionFactory()中的FluentConfiguration.cs中发生异常:创建SessionFactory时使用了无效或不完整的配置。我该怎么做才能避免这种例外?
PS我看到了this帖子,但它没有帮助我
编辑: 异常消息“以下类型不能用作代理:\ nExamples.FirstProject.Entities.Employee:方法set_Id应为'public / protected virtual'或'protected internal virtual'\ nExamples.FirstProject。 Entities.Product:方法set_Id应该是'public / protected virtual'或'protected internal virtual'\ nExamples.FirstProject.Entities.Store:方法set_Id应该是'public / protected virtual'或'protected internal virtual'“string
异常来源:“NHibernate”
异常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()在d:\ CSharp \ NH \ NH \ nhibernate \ src \ NHibernate \ Cfg \ Configuration.cs:第958行\ r \ n位于d:\ CSharp \ NH \ NH \ nhibernate \中的NHibernate.Cfg.Configuration.BuildSessionFactory() src \ NHibernate \ Cfg \ Configuration.cs:第1250行\ r \ n在FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()中的C:\ _ WorkProjects \ _nHibernate \ jagregory-fluent-nhibernate-c24de5a \ src \ FluentNHibernate \ Cfg \ FluentConfiguration。 cs:第231行“string
答案 0 :(得分:4)
Windman转到(Examples.FirstProject - >实体 - >和(Employee.cs,Product.cs和Store.cs)
更改Id属性:
public virtual int Id { get; private set; }
要:
public virtual int Id { get; set; }
答案 1 :(得分:0)
您的类型,Examples.FirstProject.Entities.Employee应将ID属性设置为
public virtual int ID { get; set; }