【发布时间】:2012-10-14 14:57:50
【问题描述】:
项目结构:
有一个模块文件夹,我需要在其中添加数据库并在其中创建存储库, 其他模块和程序集可以使用它。 新:将其更改为先前已证明的将配置文件放置在根应用程序中的状态, 仍然有错误。 这篇文章已完全编辑。
数据库位置:
location : ....\db\db.sdf(比卖家的app.config高2层)
App.Config 文件
位置:modules\ModuleX\(以前)
新位置:Shell\(主项目)
新版本:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="MyRecordzContext" connectionString="metadata=res://*...
</connectionStrings>
</configuration>
2个嫌疑人: providerName="System.Data.EntityClient"
LocalDbConnectionFactory
错误信息:
错误行: TblMyRecord MyRecord = context.MyRecords.First(w => w.MyRecord == stMyRecord);
错误: 在应用程序配置文件中找不到名为“MyRecordzContext”的连接字符串。
目标:如何更改连接字符串,我的 app.config 以使应用程序按预期工作
这里使用了 EF 5.0、SQL CE、Prism、WPF、MVVM、C#
错误:
错误: 'System.Windows.Application' 的类型初始化程序引发了异常。
在应用程序运行时出现。
错误似乎出现在任何构建之前。
堆栈跟踪:
PresentationFramework.dll!System.Windows.Application.Application()
Xz.Shell.exe!Xz.Shell.App.App()
Xz.Shell.exe!Xz.Shell.App.Main()
[Native to Managed Transition]
[Managed to Native Transition]
mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile, System.Security.Policy.Evidence assemblySecurity, string[] args)
Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state)
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state)
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart()
[Native to Managed Transition]
【问题讨论】:
标签: c# entity-framework sql-server-ce prism entity-framework-5