Code first approach in dapper

c# dapper entity-framework

Question

I have a requirement to complete an application. My personal preference is to go with ORMs for this purpose.

I haven't used any ORMs yet and I have little knowledge about EntityFramework. Recently I heard of Dapper and have thought of using it.

My question is: is it possible in Dapper to use a code first approach to create a database from classes like in EntityFramework?

Is it good idea use EntityFramework for database creation purposes and query using Dapper?

Accepted Answer

My question is in EntityFramework we have Code first approach to create Database from classes. Likewise is it possible to do in Dapper ?

Not at all. In dapper only map an existing database. Dapper is a set of extenstion methods for IDbConnection that can help you map a retuned data into c# poco classes.

Is it good combine EntityFramework for that Db creation purpose and query using Dapper ?

No. Use one or another. Also if you create a db using entity framewok it is already mapped into c# classes so there is no need to use dapper.

If not possible, then please suggest any work around for if it is there..

Use entity framework code first. It is simply awsome. You just have to create model classes whith some data annoatations which you have to do anyway if you use ORM and you bascly have whole database and data access layer ready to use. You can also use DB first or model first in Entity frameowkr if you want. First link form google seems to be a good tutorial on code first: https://msdn.microsoft.com/en-us/data/jj193542.aspx




Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why