【发布时间】:2010-06-19 16:57:14
【问题描述】:
我不断收到此错误:
Microsoft.Practices.Composite.Modularity.ModuleInitializeException was unhandled
Message=An exception occurred while initializing module 'DiagrammerModule'.
- The exception message was: An exception has occurred while trying to add a view to region 'MainRegion'.
- The most likely causing exception was was: 'System.ArgumentException: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.
at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
at System.Data.EntityClient.EntityConnection..ctor(String connectionString)
at System.Data.Objects.ObjectContext.CreateEntityConnection(String connectionString)
at System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName)
....
连接字符串存储在 app.config 中,如下所示:
<connectionStrings>
<add name="DBEntities" connectionString="metadata=res://DataAccessLayer/EntityDataModel.csdl|res://*/EntityDataModel.ssdl|res://*/EntityDataModel.msl;provider=System.Data.SqlServerCe.3.5;provider connection string="Data Source=|DataDirectory|\DB.sdf;Password=password;Persist Security Info=True"" providerName="System.Data.EntityClient" />
</connectionStrings>
其中 DataAccessLayer 是保存模型和实体的 DLL 的名称。
那段代码有什么问题?
感谢您的帮助。
【问题讨论】:
标签: wpf entity-framework connection-string