I could not find this in the documentation, but I am wondering how I can setup the ObjectContext without using the web.config to store the connection string.
I noticed while looking at the generated code for the base ObjectContext that there are three constructors. One takes a EntityConnection as a parameter and another version takes a connection string.
Is there a way to do this?
Thanks.
Connection String without web.config?
You can use the ObjectContext constructor that takes a connection string, like in the following example:
As an alternative, you can use the constructor that takes an EntityConnection parameter, initializing the EntityConnection using the EntityConnectionStringBuilder class.
Code: Select all
Entities1 db = new Entities1("metadata=res://*/Model2.csdl|res://*/Model2.ssdl|res://*/Model2.msl;provider=Devart.Data.Oracle;provider connection string=\"User Id=andreyr;Password=*;Server=*;Persist Security Info=True\"")
-
- Posts: 3
- Joined: Wed 09 Feb 2011 21:24
Thanks Andrey, but that doesn't help much. See, I'm using a DomainContext and not newing up the entities like you are.
I have no idea how to handle this and we cannot allow the connection string to be in the app.config.
Code: Select all
[EnableClientAccess()]
public class ProjectStaffingService : LinqToEntitiesDomainService
-
- Posts: 3
- Joined: Wed 09 Feb 2011 21:24