locked
WCF Data Service using two different databases RRS feed

  • Question

  • I have two databases, DB1 and DB2. Both databases have different schema's and tables.

    I also have a WCF Data Service (using Entity Framework) which currently connects to DB1. I would like to include a table from DB2 into this service as another entity. I was wondering if this is possible, thanks!

    Thursday, April 10, 2014 3:25 PM

Answers

  • Instead of using stored procedures, I went with creating a new service that has its own DbContext and it's own connection string. It seems to be working :) Thanks again for your help!

    Monday, April 21, 2014 6:51 PM

All replies

  • Hello Moneka,

    With the rreleased provider, it is not possible. You may need to implement a custom provider (Alex has a great series about that here: 

    http://blogs.msdn.com/b/alexj/archive/2010/01/07/data-service-providers-getting-started.aspx)

    in which you can definitely take the query in the form of IQueryable (expression tree) and run it on multiple underlying providers and "combine" the results. It's a lot of work though and combining the results to get a correct behavior is also not easy.

    Thanks,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, April 11, 2014 6:53 AM
    Moderator
  • Yeah I read the series a bit and felt it was a bit too complicated for what I needed. Essentially what I need to do is expose a service that can have independent entities from 2 different databases available.

    An approach I'm taking is creating a new service within that project, establishing a new entity etc. Therefore, exposing each service for each database. So far I'm not sure if it's going to work but there's no harm in trying. This would give me a little bit more flexibility - the only constraint I see so far is that I will not be able to have relationships established between those databases. At this point it is not a concern for me however I'm not sure if in the future it will be.

    If there's another way of approaching this issue, any input ideas or advice is deeply appreciated!

    Thanks,

    Moneka

    Friday, April 11, 2014 7:07 PM
  • Hi,

    WCF Data Service can support the stored produce by exposing custom service methods. And with the SP, it is allowed to link a different database as far as I know. You can consider this.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, April 15, 2014 8:38 AM
    Moderator
  • The thing I was trying with creating another totally different service didn't work :(

    I'll give this a try and let you guys know :) Thanks!

    Tuesday, April 15, 2014 5:24 PM
  • I know it works really well with views...
    Tuesday, April 15, 2014 5:29 PM
  • Instead of using stored procedures, I went with creating a new service that has its own DbContext and it's own connection string. It seems to be working :) Thanks again for your help!

    Monday, April 21, 2014 6:51 PM
  • That is great, glad to hear you find a solution and share it with us.  ;=)

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, April 22, 2014 6:22 AM
    Moderator