Answered by:
EF model designer or code-first?

Question
-
Hi,
I'm a newbee in EF so I would like to get advice which path to choose. There's model(edmx) designer which I find very easy to use and I learned EF easily because of it. There's also code-first which I just learned recently so I'm not yet familiar with it. I'm going to write an application from scratch and I'm at the point of deciding which approach I should choose. I would like to know the advantage and disadvantage of each one and which one has better performance. Maybe it's just a matter of preference but I would like to hear advice from you experts.
Thanks in advance.
Wednesday, February 15, 2012 6:37 AM
Answers
-
Hi khoy,
Welcome!
I think you can refer this blog here: http://blogs.msdn.com/b/adonet/archive/2011/03/07/when-is-code-first-not-code-first.aspx
BTW, the Migration supports Code First only now!
Have a nice day.
Alan Chen[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Thursday, February 16, 2012 8:33 AM -
If you are not afraid to start tweaking the code generation template and even develop a custom plugin into the designer, go with the database- or model-first.
You can add custom attributes to the entitie s, complex types, properties, function imports, etc. and generate lots of code you'd otherwise have to write by hand.
Probably not something you'd do for a small project, but for bigger ones the time spent tweaking and extending EF pays off. Plus most of the stuff will be usable in other projects as well.
----------------------------------
http://jendaperl.blogspot.com
A Perl developer in the world of C#- Marked as answer by Alan_chen Thursday, February 23, 2012 9:23 AM
Thursday, February 16, 2012 2:02 PM
All replies
-
Hi khoy,
Welcome!
I think you can refer this blog here: http://blogs.msdn.com/b/adonet/archive/2011/03/07/when-is-code-first-not-code-first.aspx
BTW, the Migration supports Code First only now!
Have a nice day.
Alan Chen[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Thursday, February 16, 2012 8:33 AM -
Alan,
That's a great article, thank you! So in EFv4.1 edmx can be code-generated as derived class of DBContext therefore it's just a matter of preference whether I use the designer or code to define the model.
But currently I'm using v4.0 and the generated class is derived from EntityObject. So my choices really should be are...
EntityObject or DBContext
Of the two which is better and is DBContext available in EFv4.0?
Thursday, February 16, 2012 10:45 AM -
If you are not afraid to start tweaking the code generation template and even develop a custom plugin into the designer, go with the database- or model-first.
You can add custom attributes to the entitie s, complex types, properties, function imports, etc. and generate lots of code you'd otherwise have to write by hand.
Probably not something you'd do for a small project, but for bigger ones the time spent tweaking and extending EF pays off. Plus most of the stuff will be usable in other projects as well.
----------------------------------
http://jendaperl.blogspot.com
A Perl developer in the world of C#- Marked as answer by Alan_chen Thursday, February 23, 2012 9:23 AM
Thursday, February 16, 2012 2:02 PM