Which ORM should i be using for .Net in 2016 to talk to SQL server? [closed] Which ORM should i be using for .Net in 2016 to talk to SQL server? [closed] asp.net asp.net

Which ORM should i be using for .Net in 2016 to talk to SQL server? [closed]


The options you mentioned are not all ORMs, in this 3 the only ORM is EF. there are other popular ORMs in .net including:

  • NHibernate
  • LLBLGen pro
  • ActiveRecord

Most of them support LINQ. EntityFramework is the younger one but it's integration with VS and being available out of the box is making it the most popular ORM in .net and it replaced LINQ to Entities not LINQ itself.LINQ (Language-Integrated Query) as defined in msdn can be used with different datasources.

LINQ is a set of features that extends powerful query capabilities to the language syntax of C#. LINQ introduces standard, easily-learned patterns for querying and updating data, and the technology can be extended to support potentially any kind of data store. The .NET Framework includes LINQ provider assemblies that enable the use of LINQ with .NET Framework collections, SQL Server databases, ADO.NET Datasets, and XML documents.

There are two different syntaxes to use LINQ mostly known as Fluent syntax and Query syntax.

If your new to .net as you mentioned, I suggest using EF with fluent syntax it would be the quickest way to start querying database in .net.


The short answer is Entity Framework.

I think what's confusing you is that you can use Linq Lambda and Linq Query syntax with Entity Framework. But the future (in my opinion) is Fluent API.

I've been using Entity Framework 7 (pre-release) and I get the impression that it's focused on Fluent API. Which is fine with me because I like it much better than Linq syntax.


Try Vega https://github.com/aadreja/vega it is simple to use and one of the fastest .net ORM with a lot of exciting features.

Following are steps to begin:-

1) Create an Entity class derived from Vega.EntityBaseExample: -

[Table(NeedsHistory = true)]public class Country : EntityBase{    [PrimaryKey(true)]    public int Id { get; set; }    public string Name { get; set; }    public string ShortCode { get; set; }}

2) Perform CRUD operations

Insert - Simply create Entity & set properties for Insert. Create a connection object, pass it to Repository & call Add method which will return Id of newly create record

Country country = new Country()    {        Name = "India",        ShortCode = "IN",        CreatedBy = 1  //user id created record    };using (SqlConnection connection = new SqlConnection(conString)){     Repository<Country> countryRepo = new Repository<Country>(connection);     int result = (int)countryRepo.Add(country);}

Update - To update record use Update method of repository

City city = new City(){    Id = 1,    Name = "Ahmedabad",    State = "GU",    CountryId = 1,    Longitude = 102.23m,    Latitude = 124.23m,    UpdatedBy = 1};using (SqlConnection con = new SqlConnection(connectionString)){     Repository<City> cityRepo = new Repository<City>(con);     bool result = cityRepo.Update(city);}

Read List - Reads all records with specified criteria & converts it to enumerable object which can be converted to List.

//read all recordsusing (SqlConnection con = new SqlConnection(connectionString)){     Repository<City> cityRepo = new Repository<City>(con);     List<City> cityList  = cityRepo.ReadAll().ToList();}//read all with specified dynamic criteriausing (SqlConnection con = new SqlConnection(connectionString)){     Repository<City> cityRepo = new Repository<City>(con);     List<City> cityList = cityRepo.ReadAll("Name=@Name", new { Name = "Ahmedabad" }).ToList(); //Dynamic criteria}

Refer more documentation at https://github.com/aadreja/vega/wiki/Repository