background preloader

DSL and EF

Facebook Twitter

Performance Considerations for EF 4, 5, and 6. Updated: October 23, 2016 By David Obando, Eric Dettinger and others Published: April 2012 Last updated: May 2014 Object-Relational Mapping frameworks are a convenient way to provide an abstraction for data access in an object-oriented application.

Performance Considerations for EF 4, 5, and 6

For .NET applications, Microsoft's recommended O/RM is the Entity Framework. How To Improve the Performance of TPT Inheritance Mapping in Entity Framework - Falafel Software Blog. Table-per-type (TPT) inheritance mapping in Entity Framework is one of two options for representing object hierarchies in a database, the other option being table-per-hierarchy (TPH).

How To Improve the Performance of TPT Inheritance Mapping in Entity Framework - Falafel Software Blog

Out of the box, one is correct relational design with poor performance, and the other is, in neutral terms, denormalized design with good performance. In this article I will describe the differences between the two and demonstrate a way to fix the performance penalty of using the TPT mapping strategy. TPT vs TPH Mapping. Resolving corruption in SQL Server Compact Edition database files.

Fusonic Digital Manufactory Austria. Using the cached db model store saves ~3.5 seconds on my I7 developer machine when using a model with about 80 entities.

Fusonic Digital Manufactory Austria

Important: Since the model store has to be invalidated and rebuild every time your model changes, this method will only make sense if your entities are located within an isolated assembly. Otherwise the cache will be invalidated every time you change a line in your code and so you wont be saving anything. Note that you should only enable DbContextStore during normal run scenarios without migrations. Migrations are currently not supported and will crash. EF5 Migrations: Multiple Data Contexts in a Single Database. Consider this: an application is built up from multiple modules, each with a different set of entities and data contexts.

EF5 Migrations: Multiple Data Contexts in a Single Database

All modules’ data entities should be saved in a single database and the contexts should support automatic migration. Sounds like a reasonable requirement, right? We’ll, you can’t do that with EF. Not with EF5 nor with EF6 (as far as I can tell from the current alpha version). The problem is this: The data context stores it’s models and mappings in the history table. 10 Tips to Improve your LINQ to SQL Application Performance. Hey there, back again.

10 Tips to Improve your LINQ to SQL Application Performance

In my first post about LINQ I tried to provide a brief(okay, bit detailed) introduction for those who want to get involved with LINQ to SQL. In that post I promised to write about a basic integration of WCF and LINQ to SQL working together, but this is not that post. Since LINQ to SQL is a code generator and an ORM and it offers a lot of things, it is normal to be suspicious about performance of it. These are right up to a certain point as LINQ comes with its own penalties. But there are several benchmarks showing that DLINQ brings us up to %93 of the ADO.NET SQL DataReader performance if optimizations are done correctly. [Entity Framework] Using Include with lambda expressions » Thomas Levesque's .NET blog. I’m currently working on a project that uses Entity Framework 4.

[Entity Framework] Using Include with lambda expressions » Thomas Levesque's .NET blog

Even though lazy loading is enabled, I often use the ObjectQuery.Include method to eagerly load associated entities, in order to avoid database roundtrips when I access them: Or if I also want to eagerly load the product: Tracing and Caching Provider Wrappers for Entity Framework 4 in C# for Visual Studio 2010. What's New in Entity Framework 6 (Plus How To Upgrade!) Practical .NET What's New in Entity Framework 6 (Plus How To Upgrade!)

What's New in Entity Framework 6 (Plus How To Upgrade!)

The latest version of the technology works fine with the Microsoft .NET Framework 4 and Visual Studio 2010. Here's some of what's new (along with how to move your applications to EF6). Entity Framework 6 (EF6) introduces a whole bunch of changes, but the major one is the separation of EF from the Microsoft .NET Framework. EF is now a standalone package you add on a project-by-project basis through NuGet (see "Upgrading to Entity Framework 6"). Stuff for Free Among the reasons you should upgrade to EF6 are the features you get without any work on your part. EF6 also eliminates an infrequent but annoying bug: Before EF6, if you had a class in your application that duplicated the name of one of your EF classes, EF would complain the entity name was ambiguous, even if the two classes were in different namespaces. How To LINQ To SQL: Part III.

Introduction This article is the third in a series outlining how to translate LINQ expression trees to SQL statements that can be executed against multiple RDBMS systems and not just Microsoft's SQL Server offerings.

How To LINQ To SQL: Part III

The articles will also illustrate how to: Correctly and comprehensively translate binary and unary expressions that have valid translations into SQL. Translate function calls (e.g., customer.FirstName.ToUpper()) that have SQL equivalents. Mix: Getting my head around Oslo, M and MGrammar. Improving Entity Framework Query Performance Using Graph-Based Querying. Introduction Microsoft ADO.Net Entity Framework (EF) has some limitations in querying complex data models which result in sub-optimal performance and code complexity (which itself leads to software maintenance concerns).

Improving Entity Framework Query Performance Using Graph-Based Querying

Inheritance has probably the largest (negative) impact on performance in EF. In case of non-trivial inheritance hierarchies (using TPT), the performance of EF queries drops significantly. This is well-known and Microsoft is working on it (see the June 2011 CTP release of EF). T4 (Text Template Transformation Toolkit) Code Generation - Best Kept Visual Studio Secret. Domain-Specific Languages. Extensible Application Markup Language (XAML) Click here to download a zip file with all of the PDF files.

Domain-Specific Languages

Audience The languages documentation is intended for use in conjunction with publicly available standard specifications, computer language design and implementation art. It assumes that the reader either is familiar with this material or has access to it. The technical documentation provides the following levels of audience support: Implementer: Conceptual and reference information for an implementation of one or more protocol specifications for a given task or scenario. Current Specifications Previously Published Specifications More Information. Customizing Entity Classes in VS 2010 - Entity Framework Design. When VS 2010 ships it will include some significant improvements to our code generation story for the Entity Framework. The basic idea is to make use of T4 templates for code generation and ship strong integration into the Entity Framework Designer to make the experience of customizing those templates as seamless as possible.

Below Sanjay from our Tools team outlines what will be possible once VS 2010 is released. Customize the code generated by the Entity Designer with T4 templates In Visual Studio 2008 SP1, the ADO.NET Entity Designer generates classes from the CSDL portion of the EDMX file using the EntityClassGenerator APIs. Numerous customers have asked us how to customize the code generation for a variety of scenarios including: While the SingleFileGenerator techniques described here enable some of these scenarios these techniques are generally difficult to implement and install or are tricky to debug and customize. How to: Use Wizards with Project Templates.

Visual Studio provides the IWizard interface that, when implemented, enables you to run custom code when a user creates a project from a template. Project template customization can be used to: Display custom UI that collects user input to parameterize the template. Add parameter values to use in the template. Add additional files to the template.

Perform virtually any action allowed by the Visual Studio automation object model on a project. The IWizard interface methods are called at various times while the project is being created, starting as soon as a user clicks OK on the New Project dialog box. Most of the code that you write for custom wizards will use the DTE object, which is the main object in the Visual Studio automation object model, to customize the project. Creating Item Templates. Code Generation and T4 Text Templates. In Visual Studio, a T4 text template is a mixture of text blocks and control logic that can generate a text file. The control logic is written as fragments of program code in Visual C# or Visual Basic. The generated file can be text of any kind, such as a Web page, or a resource file, or program source code in any language.

There are two kinds of T4 text templates: Run time T4 text templates ('preprocessed' templates) are executed in your application to produce text strings, typically as part of its output. For example, you could create a template to define an HTML page: <html><body> The date and time now is: <#= DateTime.Now #></body></html> Notice that the template resembles the generated output. In addition, the template contains fragments of program code. To generate the output, your application calls a function that is generated by the template. String webResponseText = new MyTemplate().TransformText(); Your application can run on a computer that does not have Visual Studio installed. Customizing Code Generation in the ADO.NET Entity Designer - ADO.NET team blog. In previous posts, I’ve described CSDL annotations, how to extract CSDL from EDMX and introduced you to how the ADO.NET Entity Designer generates code. In this post, I’ll delve into replacing the EntityModelCodeGenerator with a SingleFileGenerator you create.

Now, why would you want to do such a thing? Well, there are a number of scenarios where this is interesting and the good news is its fairly straight forward to do and there are lots of samples and documentation to help you get there. EntityClassGenerator Class (System.Data.Entity.Design) Generates object context and entity classes (object layer code) from conceptual schema definition language (CSDL) files. public sealed class EntityClassGenerator The EntityClassGenerator type exposes the following members.