.net - Entity Framework custom config file -
my application based on wcf services architecture, , 1 of services data access. service have entity framework infrustructure(such dbcontext, configuration file, poco classes..) , set console app. services have config file (app.config), need avoid it. service start single wcf-service. means request database need wcf-calls data access , call database, if rid of service , reference project referencing dll, not wcf calls, , can call database @ once. puprose need refactor current approach of getting config values app.config one. want save config file, other name "db.config". services want use database, have file in output directory, i'am not sure approach good. give me recommendation or solution task.
from understand, have base dll data access , wcf projects call data access logic first dll, passing database connection string in way base dll.
what move database specific settings properties/settings of base dll, , add config section in calling services app.config include settings.
so, have, in core wcf library, web config this:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configsections> <sectiongroup name="applicationsettings" type="system.configuration.applicationsettingsgroup, system, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089" > <section name="wcfservicelibrary1.properties.settings" type="system.configuration.clientsettingssection, system, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089" requirepermission="false" /> </sectiongroup> </configsections> <!-- other wcf library setting stuff --> <applicationsettings> <wcfservicelibrary1.properties.settings> <setting name="setting1" serializeas="string"> <value>temp1</value> </setting> </wcfservicelibrary1.properties.settings> </applicationsettings> </configuration>
and in wcf service copy lines of interest (section , settings) so:
<?xml version="1.0"?> <configuration> <!-- copied wcf service web.config --> <configsections> <sectiongroup name="applicationsettings" type="system.configuration.applicationsettingsgroup, system, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089" > <section name="wcfservicelibrary1.properties.settings" type="system.configuration.clientsettingssection, system, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089" requirepermission="false" /> </sectiongroup> </configsections> <!-- other web config stuff --> <!-- copied wcf service web.config --> <applicationsettings> <wcfservicelibrary1.properties.settings> <setting name="setting1" serializeas="string"> <value>temp1</value> </setting> </wcfservicelibrary1.properties.settings> </applicationsettings> </configuration>
[edited] works seamless, , have setting available in library this: `properties.settings.default.setting1'. inside automaticly generated internal class, access value of 'setting1' in service can expose via simple class.
Comments
Post a Comment