Managing A Debug and Release Connection String

前端 未结 9 1301
北海茫月
北海茫月 2021-01-30 18:41

What is a good approach to managing a debug and release connection string in a .NET / SQLServer application?

I have two SQL Servers, a production and a build/debug and I

9条回答
  •  囚心锁ツ
    2021-01-30 19:43

    When you open a web project you'll get 2 extra files of the Web.Config out of the box - Web.Debug.config & Web.Release.config.

    1.Add your desired connection string to those files with XSLT attributes xdt:Transform="SetAttributes" xdt:Locator="Match(name)"

    
      
    "
    

    2.Edit your csproj and add a TransformXml target:

    
        
    
    

    The second step will make the transform on each build (according to your active configuration) and not only on publish, giving you a better debug experience. I learnt it from this post.

提交回复
热议问题