none
Why Entity framework over SQL RRS feed

Answers

  • Hi mianamir,

    "Should we go for Entity framework over SQL databases" ... answer is on your choice but I will explain you why do you go with one or other.

    First to be clear that is the Entity framework: "Entity Framework (EF) is an object-relational mapper that enables .NET developers to work with relational data using domain-specific objects. It eliminates the need for most of the data-access code that developers usually need to write."

    When we talk about Entity Framework with Code First method we talk about process of making database and tables from our model of classes that we wrote in C# language and than via Entity framework we can generate database for us.

    This is very fast and handy process and you don't need to worry about how you database will be as long as you wrote your C# code (based on your needs and translated to relational model) everything will work. 

    Good example of Code First with Entity framework: https://msdn.microsoft.com/en-us/data/jj193542.aspx

    Its fast using LINQ/FE objects for Add/Modify/Delete/Update in your App and very easy to map business objects. It keeps a good performance when you work with a small/middle domain model and you have full control of your database through the code.

    Basically Entity Framework is very good and handy for small and middle projects to be fast with development.

    In other side we have so called Database First approach... where we can make our database through SQL code or GUI inside of SQL Server Management Studio and after we have our database we can generate our model based on our database.

    Here is a good example of that: https://msdn.microsoft.com/en-us/data/jj206878.aspx

    Via Entity Framework it will create entities for you and after modification of mapping you will generate POCO entities.

    And database first is very popular when you are designing a big or I can say enterprise application where your DBA will design you a database that you will be using accross the applications and APIs that you need. 

    It is more longer and "hardwork" process but the quality of your App will be better and all that depends on your needs.

    Conclusion: If you want to be more faster and you don't want to bother much with database design that you can go with Code first approach... and in otherwise you will go with Database first approach.

    But I strongly encourage you to research and learn with practical examples more about these two topics: Code First and Database First... so you can be more clear about them

    Hope this was helpful and clear for you...

    Best regards!


    (If this was helpful for you, vote for it and propose it as an answer)

    Saturday, June 18, 2016 11:55 AM
  • Hi Guys

              I need to know why should we go for Entity framework over SQL databases?

    Prons/Cons:

    Thanks!!

    What is a SQL database? There is T-SQL that MS and others like Sybase uses and there is P-SQL used by Oracle, which are languages. On top of that, the ORM engine any ORM engine is going to submit T-SQL or P-SQL to the DB engine for execution.

    EF is an ORM and EF is just one of several ORM(s) with nHibernate being the most mature out of all of them.

    https://en.wikipedia.org/wiki/Object-relational_mapping

    https://blogs.msdn.microsoft.com/gblock/2006/10/26/ten-advantages-of-an-orm-object-relational-mapper/

    https://dzone.com/articles/reasons-move-datatables

    http://lauteikkehn.blogspot.com/2012/03/datatable-vs-list.html

    It's about SOA and you don't return datasets and datatables in SOA, and it doesn't matter if it's a Web Service or other type of SOA service, since you have posted and ask the question in the WCF and other Web services forum.

    http://www.codeproject.com/Articles/515253/Service-Oriented-Architecture-and-WCF

    http://www.hanselman.com/blog/ReturningDataSetsFromWebServicesIsTheSpawnOfSatanAndRepresentsAllThatIsTrulyEvilInTheWorld.aspx

    If you are going to use EF, then I'll suggest that you use the DB First of EF, since it's the easiest to use out of the 3 types.

    There are no cons....

    Saturday, June 18, 2016 3:39 PM
  • This questions seems to have nothing to do with WCF. There is an Entity Framework (EF) forum available here where you should post EF related questions: https://social.msdn.microsoft.com/Forums/en-US/home?forum=adodotnetentityframework

    Anyway, the major benefit of using an object-relational mapper such as EF is that is greatly reduces the amount of data access code that needs to be written which makes an application easier to maintain, develop and test. You hide SQL and data access logic away from your custom logic.

    The major con is probably the overhead associated with it. EF will never perform better than any well-written stored procedure since it is an abstraction and EF is quite bad at handling complex queries which leads to worse performance.

    Please refer to the following link for more suggestions: https://www.quora.com/What-are-the-pros-and-cons-of-using-raw-SQL-versus-ORM-for-database-development

    Hope that helps.

    Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

    Sunday, June 19, 2016 5:09 PM

All replies

  • Hi mianamir,

    "Should we go for Entity framework over SQL databases" ... answer is on your choice but I will explain you why do you go with one or other.

    First to be clear that is the Entity framework: "Entity Framework (EF) is an object-relational mapper that enables .NET developers to work with relational data using domain-specific objects. It eliminates the need for most of the data-access code that developers usually need to write."

    When we talk about Entity Framework with Code First method we talk about process of making database and tables from our model of classes that we wrote in C# language and than via Entity framework we can generate database for us.

    This is very fast and handy process and you don't need to worry about how you database will be as long as you wrote your C# code (based on your needs and translated to relational model) everything will work. 

    Good example of Code First with Entity framework: https://msdn.microsoft.com/en-us/data/jj193542.aspx

    Its fast using LINQ/FE objects for Add/Modify/Delete/Update in your App and very easy to map business objects. It keeps a good performance when you work with a small/middle domain model and you have full control of your database through the code.

    Basically Entity Framework is very good and handy for small and middle projects to be fast with development.

    In other side we have so called Database First approach... where we can make our database through SQL code or GUI inside of SQL Server Management Studio and after we have our database we can generate our model based on our database.

    Here is a good example of that: https://msdn.microsoft.com/en-us/data/jj206878.aspx

    Via Entity Framework it will create entities for you and after modification of mapping you will generate POCO entities.

    And database first is very popular when you are designing a big or I can say enterprise application where your DBA will design you a database that you will be using accross the applications and APIs that you need. 

    It is more longer and "hardwork" process but the quality of your App will be better and all that depends on your needs.

    Conclusion: If you want to be more faster and you don't want to bother much with database design that you can go with Code first approach... and in otherwise you will go with Database first approach.

    But I strongly encourage you to research and learn with practical examples more about these two topics: Code First and Database First... so you can be more clear about them

    Hope this was helpful and clear for you...

    Best regards!


    (If this was helpful for you, vote for it and propose it as an answer)

    Saturday, June 18, 2016 11:55 AM
  • Hi Guys

              I need to know why should we go for Entity framework over SQL databases?

    Prons/Cons:

    Thanks!!

    What is a SQL database? There is T-SQL that MS and others like Sybase uses and there is P-SQL used by Oracle, which are languages. On top of that, the ORM engine any ORM engine is going to submit T-SQL or P-SQL to the DB engine for execution.

    EF is an ORM and EF is just one of several ORM(s) with nHibernate being the most mature out of all of them.

    https://en.wikipedia.org/wiki/Object-relational_mapping

    https://blogs.msdn.microsoft.com/gblock/2006/10/26/ten-advantages-of-an-orm-object-relational-mapper/

    https://dzone.com/articles/reasons-move-datatables

    http://lauteikkehn.blogspot.com/2012/03/datatable-vs-list.html

    It's about SOA and you don't return datasets and datatables in SOA, and it doesn't matter if it's a Web Service or other type of SOA service, since you have posted and ask the question in the WCF and other Web services forum.

    http://www.codeproject.com/Articles/515253/Service-Oriented-Architecture-and-WCF

    http://www.hanselman.com/blog/ReturningDataSetsFromWebServicesIsTheSpawnOfSatanAndRepresentsAllThatIsTrulyEvilInTheWorld.aspx

    If you are going to use EF, then I'll suggest that you use the DB First of EF, since it's the easiest to use out of the 3 types.

    There are no cons....

    Saturday, June 18, 2016 3:39 PM
  • I'll take that back the only con with an ORM is the developer at the wheel that doesn't know how to use an ORM effectively.

    Saturday, June 18, 2016 3:42 PM
  • This questions seems to have nothing to do with WCF. There is an Entity Framework (EF) forum available here where you should post EF related questions: https://social.msdn.microsoft.com/Forums/en-US/home?forum=adodotnetentityframework

    Anyway, the major benefit of using an object-relational mapper such as EF is that is greatly reduces the amount of data access code that needs to be written which makes an application easier to maintain, develop and test. You hide SQL and data access logic away from your custom logic.

    The major con is probably the overhead associated with it. EF will never perform better than any well-written stored procedure since it is an abstraction and EF is quite bad at handling complex queries which leads to worse performance.

    Please refer to the following link for more suggestions: https://www.quora.com/What-are-the-pros-and-cons-of-using-raw-SQL-versus-ORM-for-database-development

    Hope that helps.

    Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

    Sunday, June 19, 2016 5:09 PM