Advantages of the Code Only model in Entity Framework 4?

The Entity Framework 4.0 Futures view (CTP3 now) has a code-only modeling paradigm for mapping between your types and the database. No edmx files and no EDM designer are required.

I wanted to know what are the great benefits of Code Only vs Model First? What can be done in Code First, what cannot be done in other models (first, the first model and database)? I think that maybe more control, but I can not change the CSDL, SSDL, MSL files and my own code to get the result I need. The code-only model includes the execution of all the code that may be prone to errors, for example, when creating the wrong model or missing property definitions.

+4
source share
3 answers

This is really a matter of preference. EF Design Blog Citation:

However, many developers code as a model.

Ideally, these developers just want to write some classes of the domain and without ever touching the designer or part of XML can use these classes with Essentials. Mostly they want to write "Code Only".

http://blogs.msdn.com/b/efdesign/archive/2009/06/10/code-only.aspx

+4
source

Based on my experience, I would go for Model-First, because it allows you to model your domain in such complex ways that it would not be easy to do in Code-First. In fact, there would be several pre-simulation scenarios that you would not be able to achieve in the first version of the code. This is strictly my thinking, based on my understanding of how complex modeling can turn out. But until the EF team completes the work on Code-First, we won't find out.

Also, if you came from linq to the sql world, you would be shocked if you saw a good Entity model designer. It works great and allows you to create a complex model with very little effort on the developer's side.

+1
source

One of the immediate benefits of this is that if you are currently writing partial classes to add methods or data annotations to your entities, you can now define your model definition and methods in one place. If the model becomes complex over time, it will be difficult to hold it wherever you need to touch it, when you need to add a new field, make sure that it is checked, and add logic to it.

0
source

Source: https://habr.com/ru/post/1315446/


All Articles