Reputation: 9621
I have a connection string defined in my web.config like:
<connectionStrings>
<add name="LibraryConnectionString" connectionString="Server=.\SQLEXPRESS3;Database=Library;Integrated Security=true" />
Well...lI do not understand why when i drag-and-drop tables into a new DataClasses dbml it does not construct a default constructor specifying the connection string....
I only have constructor with params like:
public DataClassesDataContext(string connection) :
base(connection, mappingSource)
{
OnCreated();
}
I do need a default constructor for LinqDataSource..
Can anyone suggest a work-around?
Thanks
Upvotes: 2
Views: 761
Reputation: 113
Upvotes: 1
Reputation: 887415
You can make a default constructor in a separate file like this:
partial class DataClassesDataContext
public DataClassesDataContext()
: this(ConfigurationManager.ConnectionStrings["LibraryConnectionString"].ConnectionString) {
}
}
Make sure not to call OnCreated
twice.
Upvotes: 0