开发者

Why Doesn't The EntityConnection Object Contain the Login Password?

I've got an app that uses EF CTP5.

In this particular situation, i need to degrade to some classic ADO.NET (in order to read multiple result sets in a stored procedure, which EF does not support).

As such, im trying to use the existing connection string from the EntityConnection object, like this:

var ctx = (this as IObjectContextAdapter).ObjectContext;
var efCon = ((EntityConnection) (ctx.Connection)).StoreConnection;
var con = new SqlConnection(efCon.ConnectionString);
con.Open(); // exception thrown

When i debug, i see that the ConnectionString does not contain the password, only the data source, username, database, etc.

Is this a security thing开发者_StackOverflow why they've removed it? Does EF hide the password somewhere and only use it when it executes stored procedures itself?

The EF connection string is not like classic ADO.NET connection strings, as it has metadata info.

So it looks like im going to have to strip out the part of the connection string that i need, put that in the web.config and pass it through to the Repository.

Surely there must be a better way!


Try adding "Persist Security Info=True;" to the context connection string. This worked for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜