locked
C# Entity Framework 6 - Three different databases RRS feed

  • Question

  • Hi there, 

    So I'm trying to create a webpage which will help me to add new entry in one of my databases. 

    PropertyPortal.Building needs information from ScheduleXBuildingData and from the UKPostCodes databases. 

    Now if that would be One database with Three tables, then it would be obvious that there is only one connection needed.

    In this case I created three Connections though all the databases reside on the same SQL Server.

    Is that recommended or is there a clever method of the connecting only once but using all three databasess from the same server ?

    This is purely efficiency / performance question.

     


    Thursday, March 23, 2017 2:53 PM

All replies

  • Hi btsDeveloper,

    >>Is that recommended or is there a clever method of the connecting only once but using all three databasess from the same server ?

    it seems that you could use raw sql to achieve it. like this:

    SELECT * FROM DatabaseA.dbo.DSNA_tblMaiin
    INNER JOIN DatabaseB.dbo.DSNB_tblMaiin ON DatabaseA.dbo.DSNA_tblMaiin.Serialnumber = DatabaseB.dbo.DSNB_tblMaiin.Serialnumber
    INNER JOIN DatabaseB.dbo.DSNC_tblMaiin ON DatabaseA.dbo.DSNA_tblMaiin.Serialnumber = DatabaseC.dbo.DSNC_tblMaiin.Serialnumber

    And entity framework with Raw SQL

    https://msdn.microsoft.com/en-us/library/jj592907(v=vs.113).aspx

    Best regards,

    Cole Wu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, March 24, 2017 9:37 AM