With the introduction of the latest major version of the Entity Framework EF6, the Microsoft Object Relational Mapping (ORM) tool has reached a new level of professionalism and is no longer a layman compared to the prestigious. NET ORM tools. The EF is fully mature and is moving beyond the previously widely used tools.
The Entity Framework, which has passed its infancy, was originally a tool for database developers and later created a sensation among agile developers in the. NET community. It has learned how to get rid of the application development model, to the normal old CLR object (POCO) model, to support testing and domain-centric software development, and not to deprive data-centric developers of the right to use. Along the way, it solves the performance problems of generating code and countless quality-related issues, and has won the favor of many database administrators (DBAs).
Starting with EF 4.1, Microsoft recognizes the complexity required by the EF and simplifies access to its functionality by introducing the DbContext API. Also, because not everyone wants to use a designer or generate code, it allows you to use your own code generation model. During this time, another significant change occurred, but not functional, grammatical, code, or performance changes. The EF team becomes more transparent and interacts more frequently with the user community, and it begins to provide feature publishing more smoothly, rather than tying them to the Microsoft. NET Framework. Since the release of the EF5 in 2012, this practice has led to two advances. First, all the Entity framework APIs are extracted from the. NET framework and combined with the unconventional functionality APIs that the team is developing at the same time. Second, the entire development effort was switched to an open source model. EF6 is publicly developed in the following websites: entityframework.codeplex.com. Not only can you understand the work of your team through meeting minutes, check-in, and downloadable nightly builds, you can also provide source code to EF6 (but under the full supervision of the EF team).
Remember that EF6 is an evolution, not a revolution. Almost all of the EF skills you have previously mastered have not changed, such as how to build the Entity Framework model and how to use EF in your application. Although EF6 developed on an ORM basis, it doesn't change the way it works. If you have invested time in learning EF, this input will not be in vain. EF6 change in some ways is still relatively large, but these changes are limited to some of the namespace changes, if you are prepared will be easy to handle. I'll tell you a few helpful resources at the end of this article.
I think the function of EF6 is divided into the following categories:
Free functionality: These features are part of the core functionality. You don't even have to know what they do, much less need to know what new code is. This group includes features that improve performance by overriding the View Generation engine and query compilation modifications, due to the stability that DbContext can achieve with open connections, and the change settings for the SQL Server database created by the Entity Framework.
Level setting feature: The big improvement is that Code one now supports mapping stored procedures, and the model created in the designer already supports this functionality. Channel 9th Video has made a lot of introductions to this feature (for example, video at the following site: BIT.LY/16WL8FZ), and the CodePlex Web site provides a detailed description of the specification, so I'm not going to repeat that information in this article.
Another change is more interesting. As I mentioned earlier, the EF6 EF APIs are extracted from the. NET Framework; they are now fully encapsulated in the NuGet package. This means that some of the features that EF5 uses, such as enumerations, spatial data support, and performance improvements, no longer depend on. NET 4.5. So, if your EF6 is using. NET 4, these features will eventually help you.
I also grouped the EF designer into this category. Starting with version 2013, Visual Studio has canceled this feature, but it is provided as an extended feature of Visual Studio. For EF6, there is a considerable benefit to having the designer as an extension feature. The team will then be able to add functionality directly to the designer, including the functionality currently provided in the Entity Framework power Tools. By separating the designer from Visual Studio, you can enable Microsoft to provide EF6 tools for Visual Studio 2012 and Visual Studio 2013.
Expert functionality: These features are features that are not available in the Basic EF application sample and that you aspire to have. There are many features in EF6 that support asynchronous querying and saving, return custom Code One convention, improve scalability with new dbconfiguration types (dependent on lower-level EF6 idbdependency parsers), Support unit test simulations, You can configure the number of retries for an unstable connection. You don't need to be a certified professional to use these features, but you'll definitely feel like an expert when you're using them.
I would also like to highlight a special category: The EF6 code that is contributed by community members. Unai Zorrilla adds Dbset.addrange and removerange that allow you to customize the complex and convenient dbchangetracker.haschanges methods. He is also developing other cool features for the EF future iterations. Erik Jensen is a SQL Server Compact (sqlce) MVP who contributes sqlcefunctions to the SQL Server functions used by LINQ to Entities queries Sqlfunctions very phase Like. The significant increase in the EF view generation rate (most notable for large, complex models) is attributed to Alireza Haghshenas and a CodePlex member named Vsavenkov. With the help of Iaki Elcoro (that is, Iceclow on CodePlex), you can now define custom migration operations. (Rowan Miller of the EF team wrote some blog posts about this feature; The first one is at the following address: BIT.LY/ZBU0W1.) The list of all participants can be found in the team blog post "available EF6 RTM", which is: bit.ly/1gmde6d.
I'll delve deeper into some of the less open topics in this article and tell you about existing resources for other topics.
The Version history page (BIT.LY/1GCT0NZ) of the MSDN Data Developer Center lists all the features, each offering one or two-sentence details and a section that provides links to more information.
Everything is solved: performance improvement and stability
Performance is a soft spot for many software projects, and the Entity Framework has received a lot of performance criticism from the start. However, every iteration of the EF has brought about significant improvements in this area.
One of the most influential factors for performance is the start time when the context is first used in the application process. However, we can improve startup time in a variety of ways. I hope you've learned about these methods from my articles or other resources, such as the MSDN article on performance issues available on the following Web site: Bit.ly/3d6aic.
The startup step that typically affects performance is the mapping view build, which the EF uses to create the relevant SQL to query each entity set in the model. These views are leveraged when the application is running, so the EF does not have to create SQL dynamically for partial queries. The view is generated regardless of whether you are using the EF designer or using Code one to create the model. To save time, you can build these views in advance and then compile them into your application.
For large and complex models, view generation is particularly time-consuming. EF6 has improved this process to make it significantly faster regardless of whether the view is generated in advance or at run time. Note that a flaw in the EF 6.0.0 version hinders this functionality, but the flaw was corrected in the EF 6.0.1 (published on the same day), using the default package obtained by NuGet. In addition, the query execution time is improved by improving the way that the runtime EF uses these build views. The view generation of small models or simple models was never a problem. However, many enterprise models have hundreds of entities, including inheritance, relationships, and other complex issues. This change will greatly benefit these enterprises.
For information on how to use the Ngen in the Entity Framework assembly, see another performance note in the Bulletin blog post EF6 published: Bit.ly/1gmde6d.
LINQ Contains compile faster the EF team constantly adjusts the way queries are created, and one of the changes that the team focuses on is how to edit queries that use LINQ Contains. More clearly, it improves the performance of the compilation process. The query execution of the database is unaffected because the generated SQL has not changed.
SQL Server Database Creation EF6 One of the improvements in stability is related to database creation. The Model-I and Code-I workflows can create databases for you. If the database is in SQL Server,ef now uses a "best practice" for the SQL Server database, configuring the database's read_committed_snapshot settings to on. This means that by default, the database creates a snapshot of itself each time it changes. When an update is performed in the actual database, the query is executed against the snapshot. I was in a recent blog post "What's that read_committed_snapshot Transaction Support for EF6 about anyway?" (What is the point of read_committed_snapshot business supporting EF6?) This feature is described in the address: Bit.ly/14fdpzi.
Reusing open connections Finally, an annoying limitation is eliminated: EF6 lets you perform context calls on open dbconnection. In the past, if you performed an EF command that uses the connection after you explicitly open a connection, or if you attempt to reuse a connection that has been opened by another context call, an exception is thrown and the following message appears, "The entity connection can only be constructed with a closed dbconnection." "Now, EF6 will be happy to let you reuse the connections you've opened.