2011-07-16 44 views
1

我有连接字符串的实体框架edmx,这是通常的EF连接字符串与元数据。为什么没有元数据的连接字符串工作?

现在我正在实施mvc-mini-profiler并编写下面的方法来创建上下文。我现在只使用sql连接字符串部分,不再使用EF连接字符串。

现在,它的工作原理,但我很好奇它是怎么获得的元数据(.csdl,.ssdl地址),如果它现在发现那为什么“新的上下文()”需要元数据

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>(); 
    } 

回答

2

的没有元数据的原因是CreateObjectContext扩展方法会在创建上下文时添加这些元数据。它使用通配符:res://*/来获取元数据。你可以检查执行here

相关问题