0

how to solve this error in migration i am using old developer code i don't know how do this i spend 3 4 hours in this but not solve please any one help me

Cannot define PRIMARY KEY constraint on column 'vOid' in table 'table1'. The computed column has to be persisted and not nullable. Could not create constraint or index. See previous errors

       public Guid VOid { get; set; }

 entity.HasKey(e => e.VOid)
                    .ForSqlServerIsClustered(false);

         entity.Property(e => e.VOid)
                            .HasColumnName("vOid")
                            .HasComputedColumnSql("(CONVERT([uniqueidentifier],json_value([value],'$._id'),(0)))")
                            .ValueGeneratedNever();
JOhns
  • 331
  • 2
  • 4
  • 13

1 Answers1

0

Would be helpful to see the table structure you are referring to, but I assume, as the error says, that the column should be "not nullable". You could give this a try:

ALTER TABLE table1
ALTER COLUMN vOid INT NOT NULL
GO
Sk83r1l4m4
  • 153
  • 11
  • i am creating database using EF code first , how to solve this error – JOhns Jan 15 '19 at 15:28
  • @JOhns If you need to know how to change the SQL Server Column type to set it to not nullable, using EF - you could refer to this answer [here](https://stackoverflow.com/a/14837349/8819015) – Sk83r1l4m4 Jan 15 '19 at 15:31