我有实体框架 edmx 的连接字符串,它通常是带有元数据的 EF 连接字符串。
现在我正在实现 mvc-mini-profiler 并在下面编写方法来创建上下文。我现在只使用 sql 连接字符串部分,不再使用 EF 连接字符串。
现在它可以工作了,但我很好奇它是如何获取元数据(.csdl,.ssdl 地址)的,如果它现在可以找到,那么为什么'new Context()' 需要元数据
public static T GetProfiledContext<T>() where T : ObjectContext
{
// create connection
var sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString);
// wrap the connection with a profiling connection that tracks timings
var profiledDbConnection = MvcMiniProfiler.Data.ProfiledDbConnection.Get(sqlConnection, MiniProfiler.Current);
// create context
return profiledDbConnection.CreateObjectContext<T>();
}