How do I make entity-framework migrations use web.config transforms?

后端 未结 1 454
一生所求
一生所求 2020-12-21 00:56

When you apply any commands like

  • \'update-database\'
  • \'add-migration\'

The EF uses the connection string in your main web.config

<
相关标签:
1条回答
  • 2020-12-21 01:11

    I think the only way to run web.config transformations locally is to use MSBuild with the following parameters, where [YourTransformationConfiguration] is the name of the configuration to use, e.g. Debug or Release:

    msbuild PathToProject /T:Package /P:Configuration=[YourTransformationConfiguration] /P:AutoParameterizationWebConfigConnectionStrings=False
    

    The output of which will be available at:

    [ProjectFolder]\obj\[YourTransformationConfiguration]\Package\PackageTmp
    

    From here you can run migrate.exe on your assembly, which is similar to running the Update-Database PowerShell script. If you used Nuget, this will be in the tools folder of the EntityFramework package. I had some trouble getting this up and running, but there's a useful answer Stack Overflow answer here:

    Getting Migrate.exe to work

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