Entity Framework : Change connection string at runtime

后端 未结 6 1708
半阙折子戏
半阙折子戏 2021-02-04 03:06

Assuming there is an ASP.NET MVC application that uses Entity Framework 6 with code-first approach and StructureMap as IoC.
Also It uses Unit Of Work pattern. Here are the c

6条回答
  •  攒了一身酷
    2021-02-04 03:44

    I am going to suggest a completely different path. Assuming you have your connection strings set up in your web.config, which you say you do, why wouldn't you use web.debug.config and web.release.config transforrms to set your connection strings appropriately?

    i.e. in web.debug.config

    
        
    
    

    and a web.release.config as such

    
        
    
    

    A very thorough explanation is available here

提交回复
热议问题