Strange, but with your code, the insert works fine if you call Save(Object)insteadSaveOrUpdate(Object)
Edit # 1
What worked for me.
Entity:
public class Human
{
public virtual int ID { get; set; }
public virtual string Name { get; set; }
}
public class HumanMap : ClassMap<Human>
{
public HumanMap()
{
this.Id(x => x.ID).CustomSqlType("Serial").GeneratedBy.Native();
this.Map(x => x.Name);
}
}
And configuration with export schema:
static ISessionFactory CreateSF()
{
return Fluently
.Configure()
.Database(PostgreSQLConfiguration.Standard.ConnectionString("Server=127.0.0.1;Port=5432;Database=fnhtest;User=postgres;Password=password"))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Program>())
.ExposeConfiguration(cfg => { new SchemaExport(cfg).Create(false, true); })
.BuildSessionFactory();
}
source
share