ASP.NET 4 General DiscussionFor ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
If I understand you correctly, this just works because LINQ to SQL embeds the connection string in the assembly and uses it as a default when no connection string is defined in the config file.
IMO, this is very undesirable as it means you need to redeploy your assemblies whenever the database connection string changes. The alternative to that is to use a connection string in the config file which is exactly what EF does.
It is possible Both ObjectContext and DbContext have a constructor that lets you pass in a connection string. That way you can hardcode the connection string so it gets embedded in the assembly: