简体   繁体   中英

.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 . In this project I'm using Entity Framework 6.x to do some data stuff.
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 ).
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?

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.

As written in the comment. Easiest is probably to create your own NuGet package. You create nuget packages with every build or manually with the NuGet explorer, it does not really matter. In your package you can then add app.config transformations that add the relevant keys to every project you add the NuGet package to. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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