EF migration shows empty Up() Down() methods

后端 未结 17 2361
花落未央
花落未央 2020-12-25 09:56

I have a local database that is currently in it\'s second version and should now go to it\'s third version.

The code for the previous migrations was generated by ano

17条回答
  •  情话喂你
    2020-12-25 10:22

    Also: Make sure any new properties you've added are public!

    In my case I was doing a migration where I added fields to an existing table and was ending up with empty Up and Down methods,

    I had something like this:

    public bool ExistingField { get; set; }
    bool NewField { get;set; }
    

    Can you spot the difference...?


    If you make this mistake rerun the migration with the same name (you probably will need to add the -Force parameter to scaffold it full).

    PS. Always make sure your project builds fully before attempting to do any kind of EF command. If your project doesn't already build you're asking for trouble.

提交回复
热议问题