Search code examples
entity-framework.net-corecode-first

EF Core - code first migration: Incorrect syntax near the keyword 'NOT'


I am following this tutorial.

Added Rating property and when run 'update-database' I got this error:

enter image description here

Tried to revert to previous migration but that says no migrations applied as DB up to date. Dropped DB table and rerun migration but still getting this. When I added another migration after, UP and DOWN methods are empty. Anyone has any idea? Thanks


Solution

  • Well, you haven't shared any code, so based purely off what the tutorial says and the image you posted, it looks like instead of:

    [Column(TypeName = "decimal(18, 2)")]
    

    You most likely have

    [Column(TypeName = "decimal(18, 2")]
    

    since it's missing a bracket in the alter clause (i.e, you need a bracket after the 2 inside the string).