开发者

Entity Framework Configuration Driven

开发者 https://www.devze.com 2023-02-21 17:27 出处:网络
I have two web services which are identical to each other apart from the configuration files. However, both use Entity F开发者_JS百科ramework 4 to store their data in a table and are currently pointin

I have two web services which are identical to each other apart from the configuration files. However, both use Entity F开发者_JS百科ramework 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消