Your startup project doesn't reference Microsoft.EntityFrameworkCore.Design

后端 未结 15 740
天涯浪人
天涯浪人 2021-02-01 12:51

I have 2 projects in my solution, I have a project with Entity Framework Core installed:

And in the other ASP.NET Web API project I have these packages:

15条回答
  •  孤街浪徒
    2021-02-01 13:09

    There is absolutely NO reason to install Microsoft.EntityFrameworkCore.Design to your API project while having a separate Data project.

    Quick solution

    When using add-migration, just add a parameter to set the -StartUpProject to your Data proj (by default I presume your startup project is the API proj).


    Example add-migration command below:

    add-migration {migration_name} -StartUpProject {your_data_proj_name} -project {your_data_proj_name} -v
    

    Example update-database command below:

    add-migration {migration_name} -StartUpProject {your_data_proj_name} -project {your_data_proj_name} -v
    

    I hope this help you guys

    PS: more info about the add-migration params can be found here

提交回复
热议问题