I created my database with entity framework - code first.
public class Customer:BaseEntity
{
public string Name { get; set; }
public string Surname { get; set; }
public string Email { get; set; }
public string Password { get; set; }
public string VerPassword { get; set; }
public string SecurityQuestion { get; set; }
public string SecurityAnswer { get; set; }
public int RolId { get; set; }
public int QR { get; set; }
}
I have a working registration page but know I added QR part which is integer. I do not want to user give any input for this and I want it to be NULL in the database.
I set all of the datas to database with this design pattern
_customerService.Add(model);
I tried to set null to QR column like this but it does not work
int? value = 0;
if (value == 0)
{
value = null;
}
model.QR = value;
The error is "Cannot implicitly convert type 'int?' to 'int'. An explicit conversion exists (are you missing a cast?)"
What can I do to set null value to QR column
QRtoint?. Otherwise you'll end up withQRbeingnot nullin your DB.