我的解決方案中有兩個項目。一個實現我的業務邏輯並定義了實體框架的實體模型。當我想從另一個項目中處理在此項目中定義的類時,我在運行時遇到了一些問題。其實,最關心的是爲什麼我不能從其他項目實例化我的所謂的TicketEntities(ObjectContext)對象?當我抓住以下異常:從解決方案中的不同項目創建ObjectContext時出現問題
The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.
我發現它的剎車在:
public partial class TicketEntities : global::System.Data.Objects.ObjectContext
{
public TicketEntities() :
base("name=TicketEntities", "TicketEntities")
{
this.OnContextCreated();
}
有例外:無法加載指定的元數據資源。 只是爲了提醒你,everthing可以從原始項目中正常工作。
有趣的是,在你發佈你的答案之前,我首先想到了這個想法,並且最初有問題,但是看起來我沒有正確保存app.config文件。所以,是的,你在寫。非常感謝。 – Levelbit 2010-03-30 15:23:36