Managing Connection String for LINQ

by Sumant 19. October 2010 15:16

This is a very common requirement, you build an application, test it and publish it and in all of the three stages your connection string changes while your dbml file still refers to the default one in your application settings file.

This is what Microsoft has to say on the reported issue - http://bit.ly/9RoD0I

I found this post by Jon very helpful in resolving the problem. The solution is very neat and you just remove the default constructor from the code designer file (.designer.cs) and add a constructor of your own where you refer to the connection string in your config file. I just tried that and it worked like a charm.

If I get any issues coz of this, i’ll update here. I am still thinking about the ‘*’ (conditions apply) - in the MS’s comment in the designer file -

//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
;)
Share   

Tags: , ,

.NET | ASP.NET | LINQ

Comments (1) -

10/21/2010 10:44:03 AM #

Sumant Dubey

Okay.. there it goes.. I modified the dbml in the visual designer and as expected, it regenerated the default constructor Foot .. I guess i will have to delete it everytime.

Sumant Dubey India

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

© 2008 Sumant Dubey

About this blog

Absolutely technical! The posts are about concepts, tricks, articles and links on technical subjects / problems which are not very obvious to understand / resolve. Purpose is to have this as the first-aid in the time of need.

RecentComments

Disclaimer

The opinions expressed on this website are my own personal opinions and do not represent my employer's view in anyway.