If you want to use the Entity Framework, you should use an ObjectContext, not a DataContext, since it is a base class from Linq-To-Sql.
When you create an Entity Data ADO.NET data model, Visual Studio generates (after you finish creating the model from the database wizard or using the constructor), a class derived from ObjectContext that has a default connection string (which you select in the Wizard). Here you can see a good tutorial from the ADO.NET team on how to start using EF.
You should not use the ObjectContext directly, at least not manually create the metadata files and point to them in your connection string (it was never believed that the DataContext class is used directly, so if I make a mistake, someone will correct me), since the wizard that I mentioned above creates all kinds of mapping data - to map SQL tables / views / other materials to Entity classes.
if you want to provide your own connection to the class, you can do it programmatically using EntityConnectionStringBuilder .
This is an example using EntityConnectionStringBuilder from MSDN
Edit: I mistakenly wrote about the DataContext, as if it were the EF base class for the code created by the constructor. This is how casperOne declared the base class for the Linq-To-Sql classes.
My answer has been modified to reflect his comment.
source share