I have two classes:
Gallery with some attributes
Location with some attributes and one gallery.
I would like to have or not a gallery in location, so I did like this:
public Gallery? Gallery { get; set; }
The problem is that I'm getting this error:
Error 3 The type 'Gallery' must be a non-nullable value type in order to use it as parameter 'T' in the generic type or method 'System.Nullable<T>'
I've been looking for this error, but I could't find any solution (at least that I understood). My question is how can I fix this situation?
Galleryis a class??, which is a decoration for a struct. IfGalleryis optional on yourLocationmodel, indicate that with a nullable id property as the foreign key. For example,public int? GalleryId { get; set; }Galleryas optional in the ORM layer, no? That way you can keep the navigational property.