实体框架6连接字符串dll应用程序配置 [英] Entity Framework 6 connection string dll app config
问题描述
我有2个项目:控制台应用程序和类库(dll)
I have 2 projects: Console Application and Class Library (dll)
我的主要项目,控制台应用程序引用我的dll。
My main project, the console app, references my dll.
在我的dll中,我创建了一个EF(实体框架)ADO模型。
In my dll I created an EF (Entity Framework) ADO model.
EF连接字符串必须在dll项目 .config
文件。
The EF connection string must be in the dll project .config
file.
问题是当我初始化一个 DbContext
它正在控制台应用程序 .config
文件中查找连接字符串。
The problem is when I initialize a DbContext
it is looking for the connection string in the Console Application .config
file.
如何告诉 DbContext
在dll .config
文件中查找连接字符串
How can I tell the DbContext
to look for the connection string in the dll .config
file ?
谢谢
推荐答案
这是配置文件的工作原理。正在运行的应用程序始终看起来是{appname} .exe.config。 DLL项目的配置文件就在这里,为您提供必须复制到正在运行的应用程序配置文件的占位符。它不与DLL一起部署。
That's how config files work. The running app always looks in {appname}.exe.config. The config file for the DLL project is just there to give you placeholders that must be copied to the running app's config file. It is not deployed along with the DLL.
这篇关于实体框架6连接字符串dll应用程序配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!