简体   繁体   English

.NET / C#库项目实体框架app.config

[英].NET/C# library project entity framework app.config

I have a Visual Studio solution with multiple projects, with one of them being a class library project . 我有一个包含多个项目的Visual Studio解决方案,其中一个是类库项目 In this project I'm using Entity Framework 6.x to do some data stuff. 在这个项目中,我使用Entity Framework 6.x做一些数据工作。
One of the other projects is using this class library, but it's not the startup project, since this entire solution will be used by multiple other solutions. 其他项目之一正在使用此类库,但它不是启动项目,因为整个解决方案将由多个其他解决方案使用。
Now I know that a library class project cannot have it's own app.config , because the app.config from the startup project is used (as stated here ). 现在我知道了一个库类项目不能有它自己的app.config,由于使用从启动项目中的app.config(如说在这里 )。
The problem I'm facing here, is that multiple other solutions will use my solution. 我在这里面临的问题是,其他多个解决方案将使用我的解决方案。 So do all of these solutions need to have their app.config configured so that it can use my solution? 那么,所有这些解决方案是否都需要配置其app.config才能使用我的解决方案?

Ideally I'd like to have my library class project use it's own app.config, but I'm guessing there is no way to do this, since I couldn't find anything on this on the internet. 理想情况下,我想让我的库类项目使用它自己的app.config,但是我猜测没有办法这样做,因为我在互联网上找不到任何东西。

As written in the comment. 如评论中所写。 Easiest is probably to create your own NuGet package. 最简单的方法可能是创建自己的NuGet软件包。 You create nuget packages with every build or manually with the NuGet explorer, it does not really matter. 您可以在每个版本中创建nuget软件包,也可以使用NuGet资源管理器手动创建nuget软件包,这并不重要。 In your package you can then add app.config transformations that add the relevant keys to every project you add the NuGet package to. 然后,您可以在包中添加app.config转换,这些转换将相关的密钥添加到添加NuGet包的每个项目中。 Further details about the config transformation with NuGet packages can be found here: http://docs.nuget.org/docs/creating-packages/configuration-file-and-source-code-transformations 有关使用NuGet软件包进行配置转换的更多详细信息,请参见: http : //docs.nuget.org/docs/creating-packages/configuration-file-and-source-code-transformations

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM