.net core 使用sql server的Fluent NhiberNate.net core 3.1

.net core 使用sql server的Fluent NhiberNate.net core 3.1,.net-core,fluent-nhibernate,.net Core,Fluent Nhibernate,最近,我开始使用.NETCore开发NhiberNate,并尝试一些简单的方法 我有一张这样的桌子: public virtual Guid Id { get; set; } public virtual string Name { get; set; } public virtual string LastName { get; set; } public virtual int ClusterId { get; set; }** Id(x => x.Id).Column("

最近,我开始使用.NETCore开发NhiberNate,并尝试一些简单的方法 我有一张这样的桌子:

public virtual Guid Id { get; set; }
public virtual string Name { get; set; }
public virtual string LastName { get; set; }
public virtual int ClusterId { get; set; }**
Id(x => x.Id).Column("Id").GeneratedBy.GuidNative();
Map(x => x.Name);
Map(x => x.LastName);
Id(x => x.ClusterId);
映射如下:

public virtual Guid Id { get; set; }
public virtual string Name { get; set; }
public virtual string LastName { get; set; }
public virtual int ClusterId { get; set; }**
Id(x => x.Id).Column("Id").GeneratedBy.GuidNative();
Map(x => x.Name);
Map(x => x.LastName);
Id(x => x.ClusterId);
现在Guid是主键,clusterid只是标识,我首先创建了表并手动在其中插入数据,在服务器端创建的Guid如下

37815D12-C7BF-4575-9786-306D56DCB86D
但是当我通过邮递员等从DB获得数据时,Guid返回如下

00000000-0000-0000-0000-000000000000
我像这样返回代码中的数据
return\u session.Query().ToList()


我尝试使用
.GeneratedBy.GuidComb()更改映射
.GeneratedBy.Guid()但不起作用。

更改
Id(x=>x.ClusterId)
映射(x=>x.ClusterId)。拥有两个Id映射可能会导致各种问题。

更改
Id(x=>x.ClusterId)
映射(x=>x.ClusterId)。拥有两个Id映射可能会导致各种问题。

非常感谢,这解决了我的问题。我想我只是通过示例误解了nhibernate映射的Id概念,因为Z ClusterId不是主键,而是标识,并且在我的表上有自动增量。非常感谢,这就解决了我的问题。我想我只是通过示例误解了nhibernate映射的id concept,因为ClusterId不是主键,而是标识,并且在我的表上有自动递增。