I\'m using Entity Framework 4 in my project. The Framework has created its own connection string, so my web.config
connectionStrings section file looks following:>
Although you can create the connection in code, as @gandjustas points out (+1), you cannot get away from having a connection string or EntityConnection
.
This is because it is not actually redundant. Yes, the database connection part is redundant, and @gandjustas showed you how to remove that redundancy. However, the entity framework connection string also contains information about your model, which is not found anywhere in the connection string you wish to keep. This model information has to come from somewhere. Were you to eliminate the entity framework's connection string and use the parameter list constructor on ObjectContext
, you would have eliminated all references to the model.