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.

Popular posts from this blog

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

Read and parse a CSV file into an array of rows and columns in C#

The following PopulateCsvIntoArraymethod used to read the CSV file into a two-dimensional array of strings.
I have included explanation of method lines, wherever needed. ///<summary> /// Populate the CSV file into an array, /// We assume that every line has the same number of fields and there may be blank lines. ///</summary> ///<returns></returns> privatestring[,] PopulateCsvIntoArray() { // Get path of CSV file. var path = Server.MapPath("~/Folder_Name/testfile.csv"); // Get the file's text using ReadAllText method. string fileData = System.IO.File.ReadAllText(path);
// Split CSV data into lines.     fileData = fileData.Replace('\n', '\r'); string[] lines = fileData.Split(newchar[] { '\r' }, StringSplitOptions.RemoveEmptyEntries);
// Get rows and columns counts. int totalRows = lines.Length;

Calculate Sum and average of two or more Textbox values using JQuery

We can calculate sum and average of values entered in textboxes with the help of small piece of jQuery code.
First of all let’s create a HTML form where we’ll ask user to enter marks in each subject, under body section add following HTML:
<tableclass="demo-table"> <trclass="label"> <tdcolspan="2">Please enter marks(0-99):</td> </tr> <tr> <td>English</td> <td> <inputtype="text"class="txtMarks"name="txtMarks"