none
Question about accessing data from a Sql Server DB using WCF and Entity Framework VS using ADO.Net (.net 4.5 on win7) RRS feed

  • Question

  • I just completed a walkthrough exercise on accessing data from a WCF service using Entity Framework on a Sql server DB (for a winform app -- VS2012). It appears to be quite an involved process compared to just adding an old fashioned ADO.Net connection string to a SqlDataAdapter.  I'm not quite at a level/(position in my career) where I can see/appreciate what appears to be added complexity to a data project.  Additionally, I am working on stepping up to the mvvm pattern (for Silverlight, WPF), and this all seems waaaayyyy more complex than simple old winforms.  I am certain that there is a valid reason for all these patterns and more complex ways to do this stuff.  I am certain that these newer ways (well, newer for me) have some advantages over the old ways (SqlDataAdapters, connection strings, ...., tightly coupled coding, ...).

    My first question is this:  for an inhouse system -- is there any benefit to accessing data via WCF and EF? 

    If the answer to my first question is -- "Take your pick over WCF/EF or ADO.Net"

    the 2nd question is -- what gains do these newer methods offer over the old styles (like is it less coding in the long run for giant enterprise projects involving several developers?)

    If the answer to question 2 is that the gains are seen mainly in giant enterprise projects involving a lot of programmers then

    Question 3 -- is there still some benefit/gain for an individual developer (one man show operation like mine) to be had? (are there gains for me besides if I plan on moving to a big programmer team). 

      I ask these questions mainly so I can focus my efforts effectively -- like if all this newer stuff is already "Has been" and I should start focusing my efforts on different technologies (that are not Microsoft based -- which has been suggested to me -- but I still would like to stay with MS if there is value in that besides supporting legacy stuff which is mainly what I do right now).


    Rich P

    • Moved by Anne Jing Wednesday, July 30, 2014 6:01 AM
    Tuesday, July 29, 2014 10:30 PM

Answers

  • For rapid develoment using a database, I'll choose an ORM like EF or nHibernate over stright up ADO.NET and SQL Command Objects any day of the week.

    .Net technology is centered around WCF and EF.

    The gains you'll get by using EF is about how to do Object Oriented Programming, because the "O" in ORM means "Object". The more you see objects work and in play, becuase objects are like independent little machines that can take care of their own needs with their behaviors (methods in an object), the more  you'll appricate what is happening. You can apply this knowedge towards designing scalabe and more rebust solitions.

    http://www.dofactory.com/Patterns/Patterns.aspx

    <copied>

    Design patterns are solutions to software design problems you find again and again in real-world application development. Patterns are about reusable designs and interactions of objects.

    <end>

    It's really about the above statements. If one knows OOP and design patterens, which an ORM takes you in that direction, then you can make some serious money. They will pay you well for the expertise.

    Thursday, July 31, 2014 2:57 PM
  • Question:  when using EF and Linq -- is there any kind of performance enhancing methods to achieve the performance you get from using stored procedures from a Sql Server DB?  Or would stored procedures from a DB just be additional objects from the Entity Model you link to ?

    EF has a couple of ways to submit T-SQL to be executed. One of the ways is that it uses the SQL Server System's sp_  -- I can't think of the name of the internal sproc EF uses to submit T-SQL, but all the benifits of using a sproc applies to internal sproc on SQL Server too.

    http://msdn.microsoft.com/en-us/data/hh949853.aspx

    The 4 e-commernece solutions of MVC, ASP.NET and WPF use the same backend of WCF and EF. You get the source code so you can see what is happening.

    http://www.dofactory.com/framework/framework.aspx

    http://blogs.msdn.com/b/alexj/archive/2009/03/26/index-of-tips.aspx

    If you have any more questions about EF, then you can post to the below forum.

    http://social.msdn.microsoft.com/Forums/en-US/home?forum=adodotnetentityframework

    Thursday, July 31, 2014 5:47 PM

All replies

  • In a previous article (Implementing a Basic Hello World WCF Service), we have learned how to create a basic WCF Service manually from scratch. In that article, we also manually created a host application, generated the proxy and configuration files, and created a test client to test the WCF Service. You can review that article to learn what a WCF Service is really like under the hood.

    Now in this article, we will implement a simple WCF Service using built-in Visual Studio WCF templates. This simple WCF Service will have only one operation, GetProduct. This operation will accept an integer input as the product ID, and connect to a backend database to retrieve the product details for the specified product ID using LINQ to Entities. The Microsoft sample database Northwind will be used for the backend database, and Visual Studio 2010 will be used as the IDE.

    In a future article (Concurrency Control of a WCF Service with Entity Framework), we will implement another operation, UpdateProduct, to update a product in the database through the Entity Framework. We will cover concurrency control in that article, and we will create a WPF test client in that article to test the UpdateProduct operation with concurrency support

    Thursday, July 31, 2014 10:13 AM
  • For rapid develoment using a database, I'll choose an ORM like EF or nHibernate over stright up ADO.NET and SQL Command Objects any day of the week.

    .Net technology is centered around WCF and EF.

    The gains you'll get by using EF is about how to do Object Oriented Programming, because the "O" in ORM means "Object". The more you see objects work and in play, becuase objects are like independent little machines that can take care of their own needs with their behaviors (methods in an object), the more  you'll appricate what is happening. You can apply this knowedge towards designing scalabe and more rebust solitions.

    http://www.dofactory.com/Patterns/Patterns.aspx

    <copied>

    Design patterns are solutions to software design problems you find again and again in real-world application development. Patterns are about reusable designs and interactions of objects.

    <end>

    It's really about the above statements. If one knows OOP and design patterens, which an ORM takes you in that direction, then you can make some serious money. They will pay you well for the expertise.

    Thursday, July 31, 2014 2:57 PM
  • Thank you all for the replies.  This is very encouraging (that I am at least going in a good direction).  Yes, I am starting to sort of get the hang of EF.  Very cool.  I am also starting to realize the power of Linq, which I guess becomes integral when you are using EF. 

    Question:  when using EF and Linq -- is there any kind of performance enhancing methods to achieve the performance you get from using stored procedures from a Sql Server DB?  Or would stored procedures from a DB just be additional objects from the Entity Model you link to ?


    Rich P

    Thursday, July 31, 2014 4:44 PM
  • Question:  when using EF and Linq -- is there any kind of performance enhancing methods to achieve the performance you get from using stored procedures from a Sql Server DB?  Or would stored procedures from a DB just be additional objects from the Entity Model you link to ?

    EF has a couple of ways to submit T-SQL to be executed. One of the ways is that it uses the SQL Server System's sp_  -- I can't think of the name of the internal sproc EF uses to submit T-SQL, but all the benifits of using a sproc applies to internal sproc on SQL Server too.

    http://msdn.microsoft.com/en-us/data/hh949853.aspx

    The 4 e-commernece solutions of MVC, ASP.NET and WPF use the same backend of WCF and EF. You get the source code so you can see what is happening.

    http://www.dofactory.com/framework/framework.aspx

    http://blogs.msdn.com/b/alexj/archive/2009/03/26/index-of-tips.aspx

    If you have any more questions about EF, then you can post to the below forum.

    http://social.msdn.microsoft.com/Forums/en-US/home?forum=adodotnetentityframework

    Thursday, July 31, 2014 5:47 PM