1
votes

I have a project that gets data from the database. I made some modifications to the database fields in the model and now I am getting the error

The 'XXX' property on 'YYY' could not be set to a 'Guid' value. You must set this property to a non-null value of type 'String'. 

XXX is the key of the class and is defined in the model as

public string XXX {get; set;}

The data type of this field in my database is uniqueidentifier.

What is the "equivalence" of this data type in mvc3?

EDIT

I tried changing the datatype of XXX to

public Guid XXX {get; set;}

but I got the error

The 'UnallocatedId' property on 'YYY' could not be set to a 'Guid' value. You must set this property to a non-null value of type 'String'.

1
is your field in database not null ? or null ?Karthik Chintala
@MartinSmith: Please see edit. The field XXX is the primary key in the database.jpo
System.Guid is the equivalent for uniqueidentifier. I think there is no casting needed. you can check this linkKarthik Chintala

1 Answers

2
votes

As it says in the error, you need to use the Guid type:

public Guid XXX { get; set; }