无效的对象名称是hibernate_unique_key

问题描述:

我有这样的错误,当我尝试保存我的实体: 无效的对象名称是hibernate_unique_key无效的对象名称是hibernate_unique_key

问题是什么? 使用SQL事件探查器,我有这个查询: 从hibernate_unique_key中选择next_hi(updlock,rowlock)

你能帮我吗?

我使用Asp.net MVC 2,夏普架构(用流利的自动映射)

谢谢

我发现它。 我需要更改Fluent的PrimaryKeyConvention并设置为本机。

public class PrimaryKeyConvention : IIdConvention 
{ 
    public void Apply(FluentNHibernate.Conventions.Instances.IIdentityInstance instance) 
    { 
     instance.Column("Id"); 
     instance.UnsavedValue("0"); 
     //instance.GeneratedBy.HiLo("1000"); 
     instance.GeneratedBy.Native(); 
    } 
} 
+0

感谢。有同样的问题和你的帖子帮助我。 – autonomatt 2010-09-30 15:07:51

+0

谢谢,也为我工作。 – Dofs 2010-10-31 15:42:10

+1

使用本地发电机(SQL自动递增)当然是不推荐的方法。 – dariol 2011-11-20 23:57:57