0

I start using Entity Framework about a year ago using Database-First approach. While reading and doing research online, I came across some terminologies that are confusing me. I was wondering if someone can help clear up some questions I have:

1) Using Database-First approach, I build my SQL Tables and create my edmx file from the database. From there, I start coding by create a Data Context and then accessing the entities. I recently read and see that I can right click in the .edmx file and "Add Code Generation Item" and then add "Ado.Net EntityObject Generator/EF 5.x DBContext Generator/EF4.x POCO Entity and etc. What is the purpose of these different code Generators? Am I suppose to implement them? When should I implement them?

2) I'm reading a lot about "object model and domain model". Is EF an object model or domain model ORM?

Thank you in advance for any information.

zXSwordXz
  • 176
  • 4
  • 15
  • Besides this, the question is far too broad for StackOverflow. Ask *one* question in the first place and make sure it is about a concrete programming problem. – Gert Arnold Sep 18 '14 at 08:16

2 Answers2

0
  1. You don't normally need to use the "Code Generation Item" option. It is used to perform changes in the version of EF being used, and you could use it to do some custom code generation. In general, you should be able to leave this option alone.

  2. EF is really an ORM (Obect-Relational Mapper). It takes objects and maps them to relations (tables). It can be used as either an object model or domain model (or both) as well depending on how you define those terms.

BradleyDotNET
  • 60,462
  • 10
  • 96
  • 117
0

Add Code Generation Item

By default classes are generated with the help of EntityModelCodeGenerator. With the help of custom code generation, you can customize this. Why you would want to do ?

One example I could give from top of my head is - if you want to implement INotifyPropertyChanged interface by every single entity generated by EDMX. By default EntityModelCodeGenerator would not do that for you. Thus, you would want to customize this.

(Please note this is just my theoretical knowledge however the above example is quite a practical situation)

Domain Model vs Object Model.

Regardless the difference one thing for sure is Domain Model is Object Model too because in both cases you are defining classes, and association. This is how I define Domain Model and Object Model.

The only major difference could be how you are defining objects; in case of Domain Model, you are completely thinking from Business point of view and defining your objects.

From what I see that it is probably EF Database first is Object Model because when I am doing Database designing I am less thinking about Business, rather I am thinking about what is to be stored.

If am making POCO then I probably will be thinking from Domain Model point of view.

In case of EF - Code First, I have started thinking from Business point of view and make my association, then after I think of how objects will be stored.

So it is just a perception and at the end whether Domain Model or Object Model, ORM i.e. EF will provide you to persist this object into the database.

I hope it helps.

codebased
  • 6,945
  • 9
  • 50
  • 84
  • Thank you so much. It really help. I now have a better understanding about the domain model vs the object model. Great explanation. – zXSwordXz Sep 18 '14 at 14:00