Using EF Core 1.1
and Asp Core 1.1
on Mac
With a model like
public class Model {
public int? Id { get; set; }
public string OtherProp { get; set; }
}
And an action
public class ModelController
{
public Model Get(int? id)
{
DbContext.Set<Model>.Find(id)
}
}
Accessing the url /model/10
fails with a message The key value at position 0 of the call to 'DbSet<Model>.Find' was of type 'int', which does not match the property type of 'Nullable<int>'
The error message is clear but my question is if there is a way to make this work, it seems like a very common use case and one that used to work in previous versions.
I tried casting id
to int?
but it didn't work. Any ideas?
Also, in case it's useful this is the line that's breaking in EF