在EF4.0中默认情况下,通过ConnectionString获取的连接字符串像这个样子的:"name=PermissionEntities"。
通过类型转换可获取实际连接到数据库的字符串:
var connectionString = (ctx.Connection as System.Data.EntityClient.EntityConnection).StoreConnection.ConnectionString;