EF and ORM.
I recently realized that is possible using 开发者_开发百科POCO to have clean classes not plumbed with EF auto generated code.
I saw the new release of EF 4.1 and the use of Code First approach and DbContext.
My questions:
- What is the difference between Code First approach and Poco approach?
- Can we use Code First (DbContext and DbSet) instead of POCO + Repository pattern?
Thanks for your time on this.
They're completely different things, and you can use them together.
POCO means that your entity classes are "normal" classes, not dependent on any specific ORM layer.
A DbContext
is an object that enables you to access the database in an object-oriented way (like ObjectContext
in earlier versions of EF).
Have a look at this tutorial for examples.
精彩评论