简体   繁体   中英

Entity Framework Configuration Driven

I have two web services which are identical to each other apart from the configuration files. However, both use Entity Framework 4 to store their data in a table and are currently pointing to the same table. How can I split these to use different tables based on some configuration setting.

Ideally I do not want to create a seperate database as I will have several of these types of twin services and my hosting provider charges more for extra database instances. Also each table should logically belong to the same database. I want the two models to point to two identical tables with different names. Is this possible.

UPDATE

If there is no method of doing this. I can make a copy of the entity and use a config entry to switch between the two models.

I think the only possible way is extracting CSDL, MSL and SSDL files from EDMX file. You will need separate SSDL and MSL for each type of configuration. SSDL is XML describing database tables and MSL is XML describing mapping between objects and table. You will have to rename table in second set of these files. Then you will use connection string using correct set of these files in your each deployment scenario.

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