locked
WCF DataService with multiple entity models RRS feed

  • Question

  • User2042042824 posted

    Hi,

    I have two different entity models (ie, 2 edmx files).I need to access these two models via wcf data service .If one edmx its possible tom connect through the following lined.

    public class WcfDataService : ODataService // testEntities is my enity

    How can I add multiple entities in this service. Pls help , its urgent.

    Thanks, Saritha.

    Tuesday, July 2, 2013 5:28 AM

Answers

  • User220959680 posted

    In your DataService derived class override the CreateDataSource method and in it figure out the right connect string, create a new instance of the EF object context for the connection string and return it. The WCF Data Service will not use the default constructor on the EF object context then, it's completely up to you construct the instance with the right connection string.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 4, 2013 5:12 AM

All replies

  • User-488622176 posted

    Unlikely. The ODataService is bound to the model. You can change the connection string to change the model binding, but I have no knowledge you can change models. The options you have : merge the models, or create 2 services.

    Tuesday, July 2, 2013 6:50 AM
  • User220959680 posted

    In your DataService derived class override the CreateDataSource method and in it figure out the right connect string, create a new instance of the EF object context for the connection string and return it. The WCF Data Service will not use the default constructor on the EF object context then, it's completely up to you construct the instance with the right connection string.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 4, 2013 5:12 AM
  • User2042042824 posted

    Hi,

    Thanks for your reply. But I didnt get the solution you mentioned here. Can you please give me a sample code snippet to do the same.

    Thanks,

    saritha.

    Thursday, July 11, 2013 2:28 AM