find a location for property in a new city

Tuesday, 15 June 2010

Cross database joins in Entity Framework4

Quite new to Entity Framework 4 I really struggled with the concept of not being able to make an Entity Data Model containing entities of tables that live across different multiple databases. I am still really quite disappointed that EF4 cannot support this and the team behind it doesn't even seem to think that cross database entities are an issue worth considering despite how long this forum has been asking for them.

Anyway, there is a cheeky little way that it can be done. I will use the example of a forum to illustrate this. I need to display posts alongside the username and email address of the contributor of that post. The problem is that the user information lives in a separate database from the post information.

Time to unleash my MS Paint skills to illustrate:

Solution

I got around this by creating a View inside the ForumDB like so:
USE ForumDB
CREATE VIEW dbo.vUserDetails
AS 
 SELECT
  u.UserID,
  u.UserName,
  c.Email
 FROM
  UserDB.dbo.UserNames u
 INNER JOIN
  UserDB.dbo.ContactInfo c ON c.UserID = u.UserID
GO


With this new View in the database I can now create an entity of it in the EDM. Go to your edmx file, right click the background and select 'Update Model from Database...'

Select the data connection to the ForumDB. Then when you are on the Choose Your Database Objects step, make sure you are on the Add tab and select Views and check the vUserDetails view:


You now have access to all your user data. You add an association to link the UserID from the Posts table (Post entity) to the UserID in your new view.


Further

You now have SELECT access to this user data but you cannot currently INSERT/UPDATE/DELETE users. In this scenario this is okay, however if you have a different objective you can still achieve this using stored procedure in the Entities to run on INSERT functions etc.

Follow britishdev on Twitter

84 comments:

  1. If you use StoredProcedures , Why EntitiyFramework isn't it? Its a shame of MS.

    ReplyDelete
  2. Bài viết rất hay: Chúng tôi chuyên cung cấp các sản phẩm chất lượng sau:



    bồn massage



    bon ngam chan



    máy massage chân



    Cảm ơn các bạn!

    ReplyDelete
  3. Bài viết rất hay: Chúng tôi có các dịch vụ in ấn chuyên nghiệp sau:



    in bao bì vỏ hộp

    in hộp bìa cứng

    ReplyDelete
  4. Bài viết của bạn rất hay!

    Công ty In Ấn Phúc Nguyên cung cấp các dịch vụ giá rẻ nhất tại hà nội:



    Báo giá in thùng carton giá rẻ nhất



    in bao bì tại hà nội



    in hộp cứng

    ReplyDelete


  5. This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to article very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.
    DedicatedHosting4u.com

    ReplyDelete
  6. Great. It is good to constantly coming up with creative ideas. Provides much needed knowledge. goal oriented blog posts and always tried to find creative ways to meet goals.

    Thanks
    Online affiliates

    ReplyDelete
  7. Great and valuable information put in this blog, thank you so much for sharing this information with us. Visit OGEN Infosystem for responsive web design and SEO Service.
    SEO Service in Delhi

    ReplyDelete
  8. Allow's transition to advance and get you familiar with either well-known or new terms i.e, directed and unaided calculations which appear to be mistaking for the greater part of the individuals.Data Analytics Courses

    ReplyDelete
  9. I realize that this content is worth to read. I expect to see more posts from you that makes me impressed just like this one. Good job!!
    jigsaw puzzle

    ReplyDelete
  10. Permainan Sabung Ayam tentunya sudah pada tahu ya, yang dimana ayam melawan ayam pertandingan yang sangat seru ini bisa kalian nonton secara live lohh, banyak yang bermain di situs kami dan merasa sangat nyaman, bagi kalian yang ingin bermain bisa kunjungi situs kami, dijamin kalian akan merasa sangat senang.

    https://www.s128apk.asia/

    https://www.s128apk.asia/daftar-s128/

    https://www.s128apk.asia/sabung-ayam-deposit-pulsa-telkomsel-dan-xl-daftar-s128/

    https://www.s128apk.asia/login-s128-cara-login-judi-sabung-ayam-online/

    https://www.s128apk.asia/link-alternatif-s128/

    ReplyDelete
  11. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. ExcelR Data Analytics Courses Any way I’ll be subscribing to your feed and I hope you post again soon. Big thanks for the use

    ReplyDelete
  12. Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more.
    data science course

    ReplyDelete
  13. Bài viết rất hữu ích

    Chúng tôi chuyên cung cấp các sản phẩm sau:

    Cây Bạc hà



    Cây bạch bộ



    Bạch Đồng nữ

    ReplyDelete
  14. Know more about Data Analytics
    I am genuinely thankful to the holder of this web page who has shared this wonderful paragraph at at this place

    ReplyDelete
  15. cool stuff you have and you keep overhaul every one of us

    data science interview questions

    ReplyDelete
  16. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.
    Correlation vs Covariance
    Simple linear regression
    data science interview questions

    ReplyDelete
  17. I am looking for and I love to post a comment that "The content of your post is awesome" Great work!

    Simple Linear Regression

    Correlation vs Covariance

    ReplyDelete
  18. This is my first time visit here. From the tons of comments on your articles.I guess I am not only one having all the enjoyment right here! ExcelR Data Analytics Courses

    ReplyDelete
  19. Amazing Article ! I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.
    Correlation vs Covariance
    Simple Linear Regression
    data science interview questions
    KNN Algorithm
    Logistic Regression explained

    ReplyDelete
  20. Amazing Article ! I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.
    Correlation vs Covariance
    Simple Linear Regression
    data science interview questions
    KNN Algorithm
    Logistic Regression explained

    ReplyDelete
  21. very well explained .I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.
    Simple Linear Regression
    Correlation vs covariance
    data science interview questions
    KNN Algorithm
    Logistic Regression explained

    ReplyDelete
  22. very well explained .I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.
    Simple Linear Regression
    Correlation vs covariance
    data science interview questions
    KNN Algorithm
    Logistic Regression explained

    ReplyDelete
  23. This comment has been removed by the author.

    ReplyDelete
  24. Very informative content and intresting blog post.Data science course in Nashik

    ReplyDelete
  25. Thanks for posting the best information and the blog is very informative.Data science course in Faridabad

    ReplyDelete
  26. Honestly speaking this blog is absolutely amazing in learning the subject that is building up the knowledge of every individual and enlarging to develop the skills which can be applied in to practical one. Finally, thanking the blogger to launch more further too.
    Data Analytics online course

    ReplyDelete
  27. Thanks for posting the best information and the blog is very helpful.data science interview questions and answers

    ReplyDelete
  28. Thanks for posting the best information and the blog is very helpful.Data science course in Varanasi

    ReplyDelete
  29. nice blog!! i hope you will share a blog on Data Science.
    data science courses

    ReplyDelete
  30. It is amazing and wonderful to see your blog. Thanks for sharing this information, this is useful to me.
    Data Science Training in Hyderabad
    Data Science Course in Hyderabad

    ReplyDelete
  31. I was basically inspecting through the web filtering for certain data and ran over your blog. I am flabbergasted by the data that you have on this blog. It shows how well you welcome this subject. Bookmarked this page, will return for extra. data science course in jaipur

    ReplyDelete
  32. Oh my goodness! a tremendous article dude. Thank you Nonetheless I'm experiencing difficulty with ur rss . Don know why Unable to subscribe to it. Is there anybody getting equivalent rss problem? Anybody who is aware of kindly respond. Thnkx Unique Dofollow Backlinks

    ReplyDelete
  33. Impressive blog to be honest definitely this post will inspire many more upcoming aspirants. Eventually, this makes the participants to experience and innovate themselves through knowledge wise by visiting this kind of a blog. Once again excellent job keep inspiring with your cool stuff.

    Data Science Training in Bhilai

    ReplyDelete
  34. Wonderful blog found to be very impressive to come across such an awesome blog. I should really appreciate the blogger for the efforts they have put in to develop such an amazing content for all the curious readers who are very keen of being updated across every corner. Ultimately, this is an awesome experience for the readers. Anyways, thanks a lot and keep sharing the content in future too.

    Data Science Course in Bhilai

    ReplyDelete
  35. Extremely overall quite fascinating post. I was searching for this sort of data and delighted in perusing this one. Continue posting. A debt of gratitude is in order for sharing. python course in delhi

    ReplyDelete
  36. Building your own educational video streaming services from scratch can be tedious not to mention the long duration you might end up taking to launch it.

    ReplyDelete
  37. You actually make it look so easy with your performance but I find this matter to be actually something which I think I would never comprehend. It seems too complicated and extremely broad for me. I'm looking forward for your next post, I’ll try to get the hang of it!
    data scientist training in hyderabad

    ReplyDelete
  38. I have express a few of the articles on your website now, and I really like your style of blogging. I added it to my favorite’s blog site list and will be checking back soon…
    data scientist training and placement in hyderabad

    ReplyDelete
  39. Very wonderful informative article. I appreciated looking at your article. Very wonderful reveal. I would like to twit this on my followers. Many thanks! .
    Data Analytics training in Bangalore

    ReplyDelete
  40. I just couldn't leave your website before telling you that I truly enjoyed the top quality info you present to your visitors? Will be back again frequently to check up on new posts.
    data scientist training in hyderabad

    ReplyDelete
  41. I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business.
    data scientist course in hyderabad

    ReplyDelete
  42. It is good to constantly coming up with creative ideas. Provides much needed knowledge. goal oriented blog posts and always tried to find creative ways to meet goals. whatsapp mod

    ReplyDelete
  43. Thank you quite much for discussing this type of helpful informative article. Will certainly stored and reevaluate your Website.
    Data Analytics Course in Bangalore

    ReplyDelete
  44. I am a new user of this site, so here I saw several articles and posts published on this site, I am more interested in some of them, will provide more information on these topics in future articles.
    data science course in london

    ReplyDelete
  45. Nice to be seeing your site once again, it's been weeks for me. This article which ive been waited for so long. I need this guide to complete my mission inside the school, and it's same issue together along with your essay. Thanks, pleasant share.
    Data Science training in Bangalore

    ReplyDelete
  46. I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. Definitely a great post. Hats off to you! The information that you have provided is very helpful. data analytics course in surat

    ReplyDelete
  47. Hi to everybody, here everyone is sharing such knowledge, so it’s fastidious to see this site, and I used to visit this blog daily business analytics course in kanpur

    ReplyDelete
  48. Very wonderful informative article. I appreciated looking at your article. Very wonderful reveal. I would like to twit this on my followers. Many thanks! .
    Data Analytics training in Bangalore

    ReplyDelete
  49. I'm hoping you keep writing like this. I love how careful and in depth you go on this topic. Keep up the great work data analytics course in kanpur

    ReplyDelete
  50. Extremely overall quite fascinating post. I was searching for this sort of data and delighted in perusing this one.
    Continue posting. A debt of gratitude is in order for sharing.
    data analytics course in kolhapur

    ReplyDelete
  51. It is imperative that we read blog post very carefully. I am already done it and find that this post is really amazing. business analytics course in surat

    ReplyDelete
  52. Amazingly by and large very interesting post. I was looking for such an information and thoroughly enjoyed examining this one.
    Keep posting. An obligation of appreciation is all together for sharing.
    data science training in gwalior

    ReplyDelete
  53. I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business. data science course in mysore

    ReplyDelete
  54. I love your blog.. very nice colors & theme. Did you design this website yourself or did you hire someone to do it for you? Plz reply as I’m looking to construct my own blog and would like to find out where u got this from. thanks a lot|data science course in Jodhpur

    ReplyDelete
  55. Extremely overall quite fascinating post. I was searching for this sort of data and delighted in perusing this one. Continue posting.
    A debt of gratitude is in order for sharing.business analytics course in kolhapur

    ReplyDelete
  56. I have bookmarked your site since this site contains significant data in it. You rock for keeping incredible stuff. I am a lot of appreciative of this site.

    ReplyDelete
  57. 360DigiTMG, the top-rated organisation among the most prestigious industries around the world, is an educational destination for those looking to pursue their dreams around the globe. The company is changing careers of many people through constant improvement, 360DigiTMG provides an outstanding learning experience and distinguishes itself from the pack. 360DigiTMG is a prominent global presence by offering world-class training. Its main office is in India and subsidiaries across Malaysia, USA, East Asia, Australia, Uk, Netherlands, and the Middle East.

    ReplyDelete
  58. I like your post. I appreciate your blogs because they are really good. Please go to this website for Data Science course in Bangalore. These courses are wonderful for professionals.

    ReplyDelete
  59. Great very helpful blog. Thanks For Sharing Such A Wonderful Blog. I will definitely go ahead and take advantage of this. Your Blog Is Very Informative. Again Thanks For Sharing This Blogs With Us. For more learning go through Skillslash.
    For Data Science Course Data Science Course In Bangalore

    ReplyDelete
  60. Thank you quite much for discussing this type of helpful informative article. Will certainly stored and reevaluate your Website.
    Data Analytics Course in Bangalore

    ReplyDelete
  61. Happy to visit your blog, I am by all accounts forward to more solid articles and I figure we as a whole wish to thank such huge numbers of good articles, blog to impart to us.https://360digitmg.com/course/project-management-professional-pmp

    ReplyDelete
  62. Nice to be seeing your site once again, it's been weeks for me. This article which ive been waited for so long. I need this guide to complete my mission inside the school, and it's same issue together along with your essay. Thanks, pleasant share.
    Data Science training in Bangalore

    ReplyDelete
  63. Nice Blog! such a informative things you are sharing ,I really liked your content. If you wanna know about "Skillslash | Training with live industry experience that gets you hired" go to Data science courses in bangalore

    ReplyDelete
  64. You have done a great job. I will definitely dig it and personally recommend to my friends. I am confident they will be benefited from this site. data science training in mysore

    ReplyDelete
  65. You completed certain reliable points there. I did a search on the subject and found nearly all people will agree with your blog.
    data science online training in hyderabad

    ReplyDelete

  66. Two full thumbs up for this magneficent article of yours. I've really enjoyed reading this article today and I think this might be one of the best article that I've read yet. Please, keep this work going on in the same quality. data science course

    ReplyDelete
  67. You re in point of fact a just right webmaster. The website loading speed is amazing. It kind of feels that you're doing any distinctive trick. Moreover, The contents are masterpiece. you have done a fantastic activity on this subject! data scientist course

    ReplyDelete
  68. Good to become visiting your weblog again, it has been months for me. Nicely this article that i've been waited for so long. I will need this post to total my assignment in the college, and it has exact same topic together with your write-up. Thanks, good share. data analyst course online

    ReplyDelete
  69. Thank you so much for ding the impressive job here, everyone will surely like your post. data science course in Indore

    ReplyDelete
  70. Thanks for sharing this great article we appreciate it, we provide instagram reels download freely and unlimited.

    ReplyDelete
  71. Are you looking for a Data Science training institute that will not only train you but also aid you in bagging a job, 360DigiTMG is the right place for you.business analytics course in trichy

    ReplyDelete