Quote for the Week

"Learn to enjoy every moment of your life"

Tuesday, October 30, 2018

What's New in .Net Core?

Microsoft .NET Core Version 2.1, a cross-platform implementation of the company’s .Net development platform, has been released, featuring improvements to build time performance and tools deployment. Version 2.0 will reach end-of-life status on September 1, 2018, and patches will no longer be provided for it.

And Microsoft expects to ship .Net Core 3 in 2019, with the first beta expected later in 2018.

Features of .NET Core


Yes, as it is the new generation .NET framework, it contains all features of .NET framework + its own new features, let’s go through them

  • Cross platform support : .NET Core is supporting development of apps that can be deployed beyond windows platform, we can deploy our apps on Linux or on MacOS.
  • Containers and Dockers support : Containers and dockers are very famous in these days, they can be easily adaptable by cloud technologies, Don’t worry .NET Core has full support of these components.
  • Performance Improvement.
  • MVC and web API merged : Before .NET Core, Developer needs to use MVC and Web API separately to create REST services using JSON, but .NET Core does job more simpler and merged them in a single module.
  • Seamless support to Microservices.
  • Command line development possible on Windows, MacOS, Linux.
  • It support adjacent .NET versions per applications.
Now let’s discuss the road ahead for .NET Core 2.1:-

Build-Time Performance: For the developers into .NET Application Development this will be bring good news as build-time performance has been improved in .NET Core 2.1 especially for incremental build. These improvements valid for both .NET build on the command line and to builds in Visual Studio. Microsoft has also made improvements in the CLI tools and in the MSBuild in order to make the tools deliver much faster experience to the developers.

.NET Core Global Tools: In .NET Core 2.1, it will include a new deployment and extensibility mechanism for tools. This new experience is similar to Node global tools. Microsoft has used the same syntax and experience. .NET Core tools are .NET Core console apps which are packaged and acquired as NuGet packages. These tools are framework dependent application by default and include all of the NuGet dependencies. This implies that a given global tool will run on any OS or chip architecture by default. Microsoft expects a whole new ecosystem of tools to establish itself for .NET. Some of these tools will be specific to .NET Core development and many of them will be general in nature.

HttpClient Performance: Outgoing network requests are important part of application performance for microservices and other types of application. .NET Core 2.1 has a new HttpClient handler which is rewritten for high performance. Microsoft is also including a IHtt[ClientFactory fearture that provides circuit breaker and other services for HttpClient calls. This new feature has been built on top of the new HttpClient handler.

Windows Compatibility Pack: When you port existing code from the .NET framework to .NET Core, you can use the new Windows compatibility pack. It provides access to an additional 20,000 APIs more than what is available in .NET Core. This includes System.Drawing, EventLog, Performance Counters, Windows Services an EventLog.

Summary

We have discussed some of the new features which are being added into .Net Core 2.1 by Microsoft. Till now the feedback and experience of the developers has been great. These improvements will make the .NET Core development even more easier and make the applications run more faster while using less memory.

Tuesday, May 15, 2018

ORM(Object Relational Mapping) in .NET

An Object Relation Mapping(ORM) library helps developers to create data access applications by programming against a conceptual model instead of programming against a relational database model.  ORMs bring lot of advantages and few of the prominent ones are -  RDBMS independent data access layer development, rapid application development, huge reduction in code, auto generation of boilerplate methods for CRUD operations and abstract access to data.

I have collected some of ORMs which can used for developing .Net Applications -


LLBLGen Pro Runtime Framework



The LLBLGen Pro Runtime Framework is an optional ORM that works in conjunction with the LLBLGen entity modeling tool. We say it’s optional because LLBLGen can also work with other ORMs such as Entity Framework.


Like Entity Framework, the LLBLGen Pro Runtime Framework is full OOP style ORM. But it differs in several ways, the first being an emphasis on performance. Though EF Core is significantly faster than classic Entity Framework, both are still considerably slower than other ORMs. Frans Bouma, author of LLBLGen Pro, hosts a performance shootout comparing materialization speed of various .NET data access / ORM implementations.


The LLBLGen Pro Runtime Framework also differs from EF/EF Core in that it is not context-bound. Each entity tracks its own changes, allowing you to manipulate an object graph in memory without holding a context open. (Which will make your DBA happy because not holding an open context also means you aren’t holding an open connection, which would otherwise interfere with database connection pooling.)



Like most ORMs for .NET Core, there are some limitations with the Core version of LLBLGen Pro Runtime Framework. However, this is mostly limited to missing features in .NET Core itself such as TransactionScope not being supported by SqlClient or fewer objects being binary serializable.

Microsoft Entity Framework



Entity Framework is one of the most advanced and feature rich ORM library from Microsoft.  Using the Entity Framework, developers can write data access code using the popular LINQ queries to retrieve and manipulate data as strongly typed objects. The Entity Framework’s ORM supports change tracking, identity resolution, lazy loading and query translation so that developers can focus on building their application specific business logic rather than wring thousands of lines of code for fundamental data access.

The Entity Framework is built on top of  ADO.NET provider model and it integrates very well with Visual Studio. It supports Domain model and Code First model and have providers for various databases like Sql Server, SQL Azure, Oracle, MySql and DB2.

NHibernate



NHibernate is the .NET sibling of popular Java ORM framework Hibernate. If you are looking for an ORM library outside of Microsoft provided libraries, NHibernate is the most probable candidate you would end up choosing. NHibernate  is a mature, open source ORM framework which is actively developed, fully featured, highly performant and successfully used in thousands of projects.


This framework is being developed for over a decade by community members and used in thousands of commercial and open source applications. NHibernate uses XML description of entities and relationships, automatically generates SQL for retrieving and manipulating data. Optionally you can describe mappings metadata with attributes in source code.

Microsoft LINQ to SQL



LINQ to SQL is another Microsoft ORM library which was released before Entity Framework. Before shipping Entity Framework, Microsoft heavily promoted Linq To Sql and it is used in many .NET applications. The LINQ to SQL provider allows LINQ to query SQL Server databases to retrieve and manipulate data as strongly typed objects. Basically it’s a semi-ORM which is meant for Sql Server and if you are looking for building generic data access code that works on any database, then Linq to Sql is not the choice for you.

ORMapster


ORMapster for Visual Studio 2013 is a simple ORM data mapper and code generator extension that does one thing: iI reads your data source and creates a data access layer with LINQ self-tracking entities. That's it. The resulting data entities can then be used in your projects, including WCF, ASP.NET MVC, Web Forms, Windows Forms and so on.


ORMapster integrates directly with Visual Studio, and versions are available for Visual Studio 2010 through 2013. To work with the LINQ entities created by ORMapster, you'll also need the ORMapster Framework NuGet package.


There's a handy Getting Started guide on the ORMapster Web site that walks you through building a data model based on the beloved Northwind sample database. Also, although there's pretty much no documentation explaining it, you might check out the ORMapster Web UI NuGet package, which appears to be a DataSourceControl optimized for data binding with ORMapster-generated entities.



There are few other less known libraries available and used in few projects – AutoMapper, EntitySpaces.NET, LightSpeed etc. For a comprehensive list of .NET ORM libraries.

Which one is the best?


Hmm... this is a tough question to answer as it highly depends on the projects to say which ORM is best for a .NET project. There are various factors we need to consider before nailing down on the ORM – availability of developer pool with a specific ORM knowledge, size, performance & scalability requirements of the target application, level of support required and  time to market factors.


In the list of available ORM libraries Microsoft Entity Framework & NHibernate stands out in the crowd. If you organization is a fan or open source community and looking for a well oiled and proven library then you should consider NHibernate.


On the other side, Microsoft is heavily investing in developing Entity Framework and in the past couple of years 5 iterations has been released.  It’s one of the most actively developed and well optimized ORM library that plays well any of the .NET technologies. The future for Entity Framework looks very promising as the big boss Microsoft is driving it. There is a good developer community available in the market with Entity Framework skills.


So, according to points above and based on your requirements choose between Entity Framework or NHibernate.