Skip to main content

Difference between Entity Framework 3.5 and Entity Framework 4.0 (What's New in Entity Framework 4.0?)

The first release of Entity Framework shipped in .NET Framework 3.5 SP1 and Visual Studio 2008. Entity Framework 4 has been released as part of the release of Visual Studio 2010 and .NET Framework 4.0.

Entity Framework 4.0 builds on Entity Framework 3.5 in the following areas:

Multi-Targeting Support: Entity Data Model Designer and Entity Framework fully support Multi-Targeting capabilities of VS 2010. You can use the designer to continue building your EF 3.5 applications or move forward to EF4. We take care of upgrading / downgrading you to the right EDMX versions and such so that you can use a single IDE to build apps using EF, regardless of the framework version you are targeting.

Model-First Development: In addition to the Database-First approach you had in EF 3.5, Entity Data Model designer in Visual Studio 2010 includes Model-First capability to allow you to start from a model, and generate database based on that model.

Code-Only Development: Write classes and have EF infer a conceptual model (no edmx file!). You can even generate DDL from the dynamic model to create the database and tables.

Foreign Key Associations: EF4 includes a new type of association called Foreign Key Association. FK associations allow you to include FK properties in your model and use those as a basis for relationship between entities. Independent Associations from EF 3.5 are still supported but FK Associations will help simplify a few scenarios such as data binding. You can now include foreign keys in your model should you choose to do so.

Lazy Loading: In addition to eager and explicit loading, related entities can be loaded automatically on demand. For example, with an Order class that has an OrderDetails property, marking this property as virtual will cause order details to be loaded from the database automatically when the OrderDetails property is enumerated.

More LINQ Operators in LINQ to Entities: More LINQ operators are supported by EF4 such as Contains, Single, SingleOrDefault and DefaultIfEmpty.

EntityDataSource support for QueryExtender, POCO and FKs: EntityDataSource control now includes support for ASP.NET QueryExtender and POCO entities. QueryExtender is a new addition to ASP.NET, which allows you to have more control over the data retrieval query of a Data Source while leveraging LINQ capabilities of EF.

Design-time support for Complex Types (with refactoring): Entity Data Model Designer in VS 2010 lets you define complex types, view complex types in the model explorer tree and refactor existing properties into complex type.

Ad-hoc native query support: EF4 supports more ad-hoc query patterns that allow you to run a store query or a command directly.

Customizable Code-Generation: EF4 leverages the T4 (Text Template Transformation Toolkit) code generation templating engine in Visual Studio. You can now write your own templates that specify exactly how you want code generation to happen; or you can modify the built-in templates such as the Entity Object Code Generator or Self Tracking Entities Code Generator templates.

Better N-Tier Support with Self-Tracking Entities: The first CTP for EF4 includes a T4 template for generating entities that track their own changes on the client, which are then serialized when sent across service boundaries and saved to the database.

Application Patterns and Testability: EF4 includes an additional interface to help you to write testable code when using the framework. In addition, we have made sure that use of patterns such as Repository and UnitOfWork are possible.

Persistence Ignorance & POCO: EF4 allows developers to use their pure domain classes without needing to implement interfaces that deal with persistence concerns. Dynamic proxies are supported for lazy loading and efficient change tracking.

POCO Change-Tracking: EF4 will support two models for tracking changes on POCO’s. By default EF will take a snapshot of the original state of your objects and then compare it to the current version when saving changes. Alternatively, you can define properties as virtual so that their state is continually tracked and kept in sync with the object state manager.

Generated SQL improvements for better performance and readability: EF4 includes a lot of optimizations to the queries generated by EF such as removal of unnecessary joins, better translations of certain functions, removal of unneeded levels of nesting, and more.

Pluralization: There is now Singularization/Pluralization support such that reverse engineering existing databases will result in models that have more meaningful names for entity types, entity sets and relationships.

CreateDatabase and DDL Provider Services: EF4 includes APIs on ObjectContext that allow you to do database creation based on a model. Provider writers can implement DDL generation capability in their providers that can take advantage of this capability.

Model Defined Functions LINQ support: Model Defined Functions allow you to define composable functions in your model using Entity SQL. You can also expose these functions such that they can be used from LINQ.

ObjectMaterialized event: Now you can write logic that is executed immediately after an object has been materialized.

Comments

Popular posts from this blog

Error 405 : ASP.NET Core Web API PUT and DELETE Methods not allowed

Recently, while working with .Net core API I came across the issue of “Error 405 — Methods not Allowed” After some research, I found out that both GET and POST requests working fine but neither PUT nor DELETE requests working. Another thing is that the PUT and DELETE request was also working fine on my local machine but failed when we host on our Azure server. When I explored the issue on the web it led me to the conclusion that WebDAVModule seems to set PUT and DELETE request methods disabled by default and due to that PUT and DELETE throw 405 errors. To make the PUT and DELETE requests work, we need to override the WebDAVModule setting in web.config file by adding the below settings under “ system.webServer ”. < system.webServer >   < modules runAllManagedModulesForAllRequests = " false " >     < remove name = " WebDAVModule " />   </ modules > </ system.webServer > There may be 2 web.config files in y...

C#: Merging Excel cells with NPOI HSSFWorkbook

In this post we’ll see how to merge the two or more cell with each other while creating the excel sheet using NPOI . Mentioned below is code to merge multiple cells, in this example we are merging first cell to fifth cell of first row (you can adjust row or cell range by passing particular parameters in CellRangeAddress). //Created new Workbook var hwb = new NPOI.HSSF.UserModel. HSSFWorkbook (); //Create worksheet with name. var sheet = hwb.CreateSheet( "new sheet" ); //Create row and cell. var row = sheet.CreateRow(0); var cell = row.CreateCell(0); ; //Set text inside cell cell.SetCellValue( "This is Merged cell" ); cell.CellStyle.WrapText = true ; //define cell range address // parameters: -> first row to last and first cell to last cell var cra = new NPOI.SS.Util. CellRangeAddress (0, 0, 0, 4); //Add merged region to sheet. sheet.AddMergedRegion(cra); Hope this solution helps you J

How to set Swagger as the default start page for API hosted on the Azure web app?

I created an Asp.Net Core 2.x Web API and configured Swagger on it, below is the code added in Configure method under Startup.cs file, for full swagger configuration, check here //Add swagger configuration app.UseSwagger(); app.UseSwaggerUI(c => {     c.SwaggerEndpoint( "../swagger/v1/swagger.json" , "Test API V1" ); }); On my local machine when I run the API it is automatically redirected to the Swagger page. However, when I hosted this API as an Azure web app it is not redirecting directly to the Swagger and to access the swagger, I had to append /swagger in the URL, for example, https://testapi.azurewebsites.net/swagger/ Solution: Set RoutePrefix to string.Empty under app.UseSwaggerUI like below: app.UseSwaggerUI(c => {     c.SwaggerEndpoint( "../swagger/v1/swagger.json" , "Test API V1" );      c.RoutePrefix = string .Empty; // Set Swagger UI at apps root }); And that’s it, now when you b...