Thanks for taking a look at my post.
I've been working with linq to sql and have generally been happy, until i just noticed that开发者_高级运维 database table names are hardcoded into the classes/dbml files-- which can't work in our environment. We need to be able to have database names completely changeable via web.config-- in one place. That's a definite requirement.
Do you know how this can be achieved with Linq To Sql? If not, does the Entity Framework behave in the same manner? Perhaps i will have to port my model.
Appreciated!
In other words, i need "Tourism_DB" in the DataContext file:
[System.Data.Linq.Mapping.DatabaseAttribute(Name="Tourism_DB")]
public partial class TourismDataContext : System.Data.Linq.DataContext
{
as well as this text in the dbml
<Database Name="Tourism_DB" Class="TourismDataContext" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007">
to NOT be used, and the value in the web.config to be used anyway.
http://weblogs.asp.net/rajbk/archive/2008/05/20/connection-strings-in-linq-to-sql-classes.aspx
note you can do this with LINQ to SQL:
Dim c As New MyClassesDataContext(ConfigurationManager.ConnectionStrings("ConnectionString1").ToString())
The method i found here worked the best http://msmvps.com/blogs/superska/archive/2009/03/13/linq-to-sql-connectionstring-in-web-config.aspx. It laid out the full process.
精彩评论