|EF7 Drops XML Modeling Favors Code First|
|Written by Kay Ewbank|
|Monday, 27 October 2014|
Microsoft is dropping some ways of modeling data in the next version of Entity Framework (EF) to make the database tool more lightweight.
In the current version of the object relational modeling tool, you have two ways to store models – in code, or using the XML-based EDMX format.
You could start a new project by creating a model (Model First), by creating a database (Database First), or by defining a model in code (Code First).
If you use the Model First technique, you create the database design in a visual designer, specifying the model in terms of the object structures, relationships and constraints. This is then converted into actual tables and indexes in the target database. If you use the Code First approach, you create your design by writing code consisting of the classes that define your database objects. However, there is a tool that can reverse engineer an existing database into code making it possible to use Code First without starting a new model from scratch.
In the forthcoming version of EF, Microsoft is dropping the EDMX model format in favor of code only. The reasons behind this aren’t entirely clear. According to Rowan Miller, Program Manager for the ADO.NET Entity Framework team, the main driver is to enable EF’s use on new platforms and new data stores. On the ADO.NET blog Miller says:
“Entity Framework is a popular data access choice for traditional client and server applications that target the full .NET Framework. This includes applications built with technologies such as WPF, WinForms and ASP.NET. As we look to the future, we believe there is value in providing the same programming model for data access on the remaining platforms where .NET development is common. This includes Windows Store, Windows Phone and the Cloud Optimized .NET that was announced at TechEd. EF7 will work on all of these platforms as well as Mono, on both Mac and Linux.”
This makes it sound as if the visual designer is being dropped, but the blog post says:
“The EF Designer was all about visualizing a model and in EF6.x we also had the ability to generate a read-only visualization of a code-based model (using the EF Power Tools). We’re still considering what is the best approach to take in EF7. There is definitely value in being able to visualize a model, especially when you have a lot of classes involved.”
That sounds as though the designer will still be included, and what is being dropped is just the XML representation.
The blog post attempts to reassure EF users, saying:
“Code First is really an alternative to the EDMX file format. Conceptually, Code First supports both the Database First and Model First workflows. Confusing… we know. We got the name wrong. Calling it something like ‘code-based modeling’ would have been much clearer.”
According to Microsoft, the benefits of dropping the Model First option are mainly that it’s easier to make changes to the model when it’s purely code based:
“Developers know how to write and debug code. While a designer is arguably easier for simple tasks, many projects end up with requirements beyond what you can do in the designer. When it comes time to drop down and edit things, xml is hard and code is more natural for most developers.”
However, the blog post does have some good(ish) news for developers with Model First projects, saying:
“We’re not trying to hide the fact that EF7 is a big change from EF6.x. We’re keeping the concepts and many of the top level APIs from past versions, but under the covers there are some big changes. For this reason, we don’t expect folks to move existing applications to EF7 in a hurry. We are going to be continuing development on EF6.x for some time.”
To be informed about new articles on I Programmer, install the I Programmer Toolbar, subscribe to the RSS feed, follow us on, Twitter, Facebook, Google+ or Linkedin, or sign up for our weekly newsletter.
or email your comment to: firstname.lastname@example.org
|Last Updated ( Monday, 27 October 2014 )|