Entity Framework | Double property that allows null

5

My property allows values double and values null . In the SQL Server Database it is set to decimal(18, 2) .

But when seto some value (ex: 5.00 ), it gives the error below.

Error:

  

The 'Valuation' property on 'Occurrence' could not be set to a 'System.Decimal' value. You should set this property to a non-null value of type 'System.Double'.

Model:

public class Ocorrencia
{
    [Key]
    public int id { get; set; }
    public double? Avaliacao { get; set; }
}

How should it get to work properly?

    
asked by anonymous 29.03.2017 / 23:15

2 answers

6

You can cast for double

ocorrencia.Avaliacao = (double)5.00;
    
29.03.2017 / 23:22
3

Possibly you are not forcing the notation to double :

ocorrencia.Avaliacao = 5.00D;
    
29.03.2017 / 23:17