Dapper and Entity framework for modeling classes

asp.net c# dapper entity-framework


I want to start using Dapper because I think it's easier to use with Stored procedures than to map every stored procedure with Entity Framework to replace CRUD operations in general.

I would like to know how can I create the POCO classes with dapper, and if it is not possible, could I create the model from the Database using Entity framework and then use the classes created with dapper?


11/18/2015 9:41:42 AM

Popular Answer

There are a number of projects where I have used dapper alongside Entity Framework / nHibernate.

There is a distinction between the POCO classes created for Dapper and the domain entities used by code first Entity Framework and you should create both.

Stored procedures will work with a shaped view of the data and do not have the responsibility of representing the entire domain.

Following single responsiblity practises the POCO classes you use should only contain those properties used by the stored procedures to are interfacing with.

If you are not using Entity Framework for data access and want to replace it completely with Dapper and stored procedures then you are failing to realise any of the benefits of an ORM and should simply hand craft the schema and the POCO classes it uses.

You can generate POCOS from a schema and tools exist to do this, given the overhead of creating your own classes which can be better tailored to the application layer I woudl suggest there would be no benefit.

11/18/2015 11:30:05 AM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow