Skip to content

Cannot update nullable short property via ExecuteUpdate / SetProperty in v10 — casting (short?) or Convert.ToInt16 fails #3673

@theunal

Description

@theunal

Description

Using Npgsql.EntityFrameworkCore.PostgreSQL v10.0.0 with EF Core 10, updating a nullable short (short?) property via expression-based update fails.

Error

System.InvalidOperationException: 'No coercion operator is defined between types 'System.Func2[Entities.Concrete.User,System.Nullable1[System.Int16]]' and 'System.Int16'.'

Steps to reproduce

using (var context = new MyDbContext())
{
    context.Users.Where(u => u.Id == id)
        .ExecuteUpdate(u => u.SetProperty(u => u.LoginFailedCount, u => (short?)0));  // or Convert.ToInt16(0), or just 0
    context.SaveChanges();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions