The byte array for guid must be exactly 16 bytes

I am trying to insert Guid into my Asp.net project as a unique identifier. We determined the column length of table 16. When I insert the data, I get an exception: Data is too long - but when I increase the length of the column, it changes to byte array for guid must be exactly 16 bytes long .

I tried adding data through NHibernate. MySQL database server, column data type - :- BINARY , and length - :- 16

 public class Myapp public Guid Id { get; set; } 

We write code to receive data from the Cs page:

 Myapp.Id =Guid.NewGuid(); 

How can i solve this?

+5
source share
2 answers

If you are using SQL Server, there is a type for the value Guid uniqueidentifier

+3
source

Try using a column with Char(16) in a MySQL database

0
source

Source: https://habr.com/ru/post/1200217/


All Articles