I'm using below code to fetch latest inserted record:
public Request GetLastRequest()
{
return _request.Find(_request.Max(p => p.Id));
}
As you can see Id
is type of Guid
:
public class Request
{
public Request()
{
Id = Guid.NewGuid();
}
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public Guid Id { get; set; }
}
After running my code, I'm getting this error:
An exception of type 'System.NotSupportedException' occurred in EntityFramework.SqlServer.dll but was not handled in user code
PS: above code works if I use int
for Id
.