Last post Sep 22, 2014 09:41 PM by Kevin Shen - MSFT
Sep 17, 2014 09:07 PM|aspn00bie|LINK
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.
Sep 19, 2014 02:21 AM|Kevin Shen - MSFT|LINK
When you create a model using the Entity Framework Designer your classes and derived context are automatically generated for you. In addition to the default code generation we also provide a number of templates that can be used to customize the code that
gets generated. These templates are provided as T4 Text Templates, allowing you to customize the templates if needed.
The code that gets generated by default depends on which version of Visual Studio you create your model in:
This page covers the available templates and then provides instructions for adding a template to your model.
If you are using entity framework version 5,please try the Ado.Net EntityObject Generator/EF 5.x
If you are using entity framework version 4,please try the Ado.Net EntityObject Generator/EF 4.x
More about the concept of the Dbcontext Generator,please refer to the link below:
For your second issue, as far as i know ,Entity Framework is an object model ORM.
It just map the table to the entity,and provide ways for you to manipulate the data.
Here are some links which can give you a right direction:
Sep 19, 2014 10:11 AM|aspn00bie|LINK
Thank you so much for clearing a bunch of questions I had but I still have one more question and would really appreciate if you can help me. I'm using Visual Studio 2010 and build a asp.net web application using .net 4.0 Framework. I created my project
and the very first thing I did was to upgrade Entity Framework to 6.0 via the NuGet Package. I then created my Database-First Model and all my SQL tables in the .edmx file, save it and start coding. I notice that the .edmx file properties>>Custom Tool value
is: EntityModelCodeGenerator. I also add a Custom Tool Namespace so I can reference it by using the "using namespace".
1) My question is, was my classes generated from EntityObject? If so, which version 6.0. Is there a way to tell?
2) Base on the material you provide, EF 6.x DBContext Generator is not available for VS2010. Therefore, if I do need to switch to the "DbContext Generator template" in my project, should I used EF 5.x DbContext Generator" with EF 6 Framework?
Thank you in advance for your help.
I backup my project and then remove "Custom Tool" and "Namespace" from my .edmx file and then open the .edmx file and right click to "Add Code Generation". Select the EF 5.x DbContext Generator, name it appropriately and click ok. I notice that it
did add the T4 Text Template with all my table classes. I realize by upgrading that I had to modify my coding which is no big deal since I'm more concern with doing it the right way.
Sep 22, 2014 09:41 PM|Kevin Shen - MSFT|LINK
For your first issue, when you use database first generate the .edmx file ,the dbclass are generated from dbcontext,.
The EntityObject Generator can be used to generate a strongly-typed ObjectContext class and entity classes that derive from EntityObject from an Entity Framework model created using the EF Designer.Once installed, you can right-click on the EF Designer surface
and select "Add Code Generation Item..." from the menu , choose the " ef 6.x entity object generator" item ,it will generate the class which from entity object in visual studio 2013.
I suggest that you can refer to the link about how to install entity object generator:
and here are some concept about Generated Code Overview:
For your second issue,as far as I know ,you can use ef 5.x dbcontext generator for ef6 framework.