nhibernate / fluent-nhibernate

Fluent NHibernate!
BSD 3-Clause "New" or "Revised" License
1.66k stars 686 forks source link

Error while mapping proxies for Entities in net9.0 #716

Closed sukreshmanda closed 3 weeks ago

sukreshmanda commented 3 weeks ago

Dotnet Version: 9.0.100-preview.7.24407.12

Fluent-NHibernate Version: 3.4.0

Code Used

public class Employee
    {
        public virtual string Name { get; set; }
        public virtual long Id { get; set; }
    }

    public class EmployeeMap : ClassMap<Employee>
    {
        public EmployeeMap()
        {
            Table("employee");
            Id(e => e.Id).CustomSqlType("Serial").GeneratedBy.Native();
            Map(e => e.Name).Column("name");
        }
    }

Error:

NHibernate.InvalidProxyTypeException: The following types may not be used as proxies:
TodoAPI.Models.Employee: method MemberwiseClone should be 'public/protected virtual' or 'protected internal virtual'
   at NHibernate.Cfg.Configuration.ValidateEntities()
   at NHibernate.Cfg.Configuration.Validate()
   at NHibernate.Cfg.Configuration.BuildSessionFactory()
   at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
hazzik commented 3 weeks ago

Update NHibernate to 5.5.2

This is a duplicate of https://github.com/nhibernate/nhibernate-core/issues/3536