Skip to main content
added 42 characters in body
Source Link
Roar
  • 2.2k
  • 4
  • 24
  • 39

I have a guid property in my entity and i want to map it to guid field in MS SQL.

 public class SomeEntity { public virtual int Id { get; set; } public virtual Guid GUID { get; set; } } 

and how can i map this to table and allow MS SQL generate this guid field
i've tried this

Id(x => x.Id).GeneratedBy.Identity(); Map(x => x.GUID).Unique().Not.Insert().Not.Update(); 

with no luck. The problem is when entity has been added it generates GUID but when i select it returns empty guid({00000000-0000-0000-0000-000000000000}).
also i've tried this

Map(x => x.GUID).Unique().ReadOnly(); 

again with no luck, so what is the solution? how to map to guid, which should be generated in MS SQL

I have a guid property in my entity and i want to map it to guid field in MS SQL.

 public class SomeEntity { public virtual int Id { get; set; } public virtual Guid GUID { get; set; } } 

and how can i map this to table and allow MS SQL generate this guid field
i've tried this

Id(x => x.Id).GeneratedBy.Identity(); Map(x => x.GUID).Unique().Not.Insert().Not.Update(); 

with no luck. The problem is when entity has been added it generates GUID but when i select it returns empty guid.
also i've tried this

Map(x => x.GUID).Unique().ReadOnly(); 

again with no luck, so what is the solution? how to map to guid, which should be generated in MS SQL

I have a guid property in my entity and i want to map it to guid field in MS SQL.

 public class SomeEntity { public virtual int Id { get; set; } public virtual Guid GUID { get; set; } } 

and how can i map this to table and allow MS SQL generate this guid field
i've tried this

Id(x => x.Id).GeneratedBy.Identity(); Map(x => x.GUID).Unique().Not.Insert().Not.Update(); 

with no luck. The problem is when entity has been added it generates GUID but when i select it returns empty guid({00000000-0000-0000-0000-000000000000}).
also i've tried this

Map(x => x.GUID).Unique().ReadOnly(); 

again with no luck, so what is the solution? how to map to guid, which should be generated in MS SQL

Source Link
Roar
  • 2.2k
  • 4
  • 24
  • 39

Fluent NHibernate map GUID type property NOT Identity

I have a guid property in my entity and i want to map it to guid field in MS SQL.

 public class SomeEntity { public virtual int Id { get; set; } public virtual Guid GUID { get; set; } } 

and how can i map this to table and allow MS SQL generate this guid field
i've tried this

Id(x => x.Id).GeneratedBy.Identity(); Map(x => x.GUID).Unique().Not.Insert().Not.Update(); 

with no luck. The problem is when entity has been added it generates GUID but when i select it returns empty guid.
also i've tried this

Map(x => x.GUID).Unique().ReadOnly(); 

again with no luck, so what is the solution? how to map to guid, which should be generated in MS SQL