Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Byte array for guid must be exactly 16 bytes long

Tags:

c#

asp.net

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

I have tried adding Data thru NHibernate. The database server is MySQL, column data type is :- BINARY and length is :- 16

public class Myapp

public Guid Id { get; set; }

We write code for getting Data from Cs page:

Myapp.Id =Guid.NewGuid();

How can I solve this?

like image 237
Abhi_Mishra Avatar asked Oct 20 '22 03:10

Abhi_Mishra


1 Answers

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

like image 70
mpacheco Avatar answered Oct 22 '22 16:10

mpacheco