Garima Bansal

Garima Bansal

  • 861
  • 681
  • 39.8k

Implicit conversion from data type nvarchar(max) to varbinary(max)

Jan 16 2023 7:01 PM

I changed the data type of a field in my model from string to byte array and I got this error when I run Update-Database code first migration method.

 

Implicit conversion from data type nvarchar(max) to varbinary(max) is not allowed. Use the CONVERT function to run this query.
 


        public override void Up()
        {
            AlterColumn("dbo.ApplicantLogins", "Photograph", c => c.Binary(nullable: false));
        }
        
        public override void Down()
        {
            AlterColumn("dbo.ApplicantLogins", "Photograph", c => c.String(nullable: false));
        }


Answers (1)