Search code examples
c#sql-serverfluent-migrator

How to update value to null using FluentMigrator


How can I update all rows to null using FluentMigrator fluent syntax? You cannot assign null to anonymous type property.

Update.Table("mytable").Set(new { supplierid = null }).AllRows();

Solution

  • I found the answer to my question. You must use DBNull.Value.

    Update.Table("mytable").Set(new { supplierid = DBNull.Value }).AllRows();