Publish Entity-Framework Code-First Migrations with no Context in the startup project

前端 未结 1 1951
日久生厌
日久生厌 2020-12-08 11:58

I am building a solution with the following Projects:

  • Main.Data - Class Library project
  • Main.API - Asp.NET MVC WebApi -
相关标签:
1条回答
  • 2020-12-08 12:54

    I can now enable Execute Code First Migrations when I create a publish profile.
    Here is what I did to achieve it:

    1. Inside Main/Web.config I changed the name of the connection string to the FQN of the context class: Main.Data.MyContext.
    2. Add a reference from Main project to Main.Data Project (which was not needed until now).

    This does the job for me.
    If anyone got a better or more educating answer, I would be happy to hear it.

    0 讨论(0)
提交回复
热议问题