Using a Guid as Id column in NHibernate throws a format exception when using MySQL

When I define an NHibernate object / mapping to use Guid as an identifier column, I get an exception. The Guid column is generated as varchar (40), but the content seems to be binary.

Is there a solution? For now I just use simple ol 'int, but it would be nice to know about future projects! :)

+5
source share
2 answers

The MySql Connector documentation states that from version 5.2 of the .NET connector, they refer to the GUID as BINARY (16) not VARCHAR (40) .

MySQL nhibernate , ( ) BINARY (16) nhibernate .

+7

: Char (36)

Connector/NET 6.1.1. - GUID- BINARY (16) Char (36). , UUID() GUID - UUID() 36- . "Old Guids = true", GUID BINARY (16).

+5

All Articles