Exclusively for you!! Trial version of Google Apps, Apply Coupon-CNHPGX6T6QRWGV!!
EDMX file.
Aug24

EDMX file.

Welcome to CodeSpread! Few lines about Entity Framework The Entity Framework is an object-relational mapping framework or O/RM.For more info on O/RM refer Magic Wand: Object-relational mapping. It was released with .NET 3.5 SP1. What we achieve with EF is the separation between the representation details like a conceptual model from the implementation details like a relational data store. EF uses mapping details to bridge the conceptual model to its data storage model. We can have a sense of independence during implementation provided by the isolation between models and layers.In this way, we can create a model of entities that hold data in an object-oriented way. This isolation helps us to model the data store in an abstract way and target potentially any data store. Architecture ref: wikipedia What is EDMX? EDMX is an extended version of the Entity-Relationship model where Entity data model specifies the conceptual model of the data. EDMX file can be seen as a container of Entity Data Model. An .edmx file is an XML file that defines a model that can be used with Entity Framework. The model is made up of a conceptual model, a storage model, and the mapping between these models. By default, an .edmx file opens with the EF Designer and it is also the recommended practice for creating and editing an .edmx file. Steps to add edmx file. Open or create the project. Right-click on the project name and select Add-> New Item . Select ADO.NET Entity Data Model template. Entity Data Model Wizard starts. Either Select ‘Empty Model’ or ‘Generate from Database’ and click Finish Wizard Over. .edmx file encapsulates the storage model, the conceptual model, and mappings. Few Terminologies Conceptual Model: This model is an abstract representation for the entity types, complex types, associations, entity containers, entity sets, and association sets mapped to a relational data store. The conceptual model is defined in CSDL in the .csdl file. Storage model: This can be defined as a relational database represented as a abstraction in conceptual model. The storage model is defined in SSDL in the .ssdl file. Mapping : This represents a bridge between conceptual model and storage model. Eager loading: Loading related objects along with the object requested in the query. Explicit loading: Delay in loading related objects along with the object requested in the query till they are requested using the ‘Load’ method on a navigation property. Lazy loading: Delay in loading related objects along with the object requested in the query till their navigation property is...

Read More
POCO vs Custom Classes/DTO
Jan04

POCO vs Custom Classes/DTO

When I started working on Entity Framework, I didn’t catch the idea of POCO initially. I started with custom classes and later came to know the advantages of POCO over custom classes. What is POCO? POCO stands for Plain Old CLR Object .It provides freedom to define object model in which objects does not inherit from specific base classes. This enhances control over the design and implementation.It basically refers to an object that does not have any persistence concerns and is not aware of persistence framework. POCO mainly supports serialization. Persistence ignorance means that business logic layer and other layers are not dependent on the design of the database, type of database,type of database framework . The flow of data between layers should be independent of any predefined process. To achieve POCO entities, these are the rules required to be followed. No more inheriting from a base class. No interface Implementation. No need for metadata or mapping attributes. Modern development approaches such as DDD (Domain-Driven Design) and TDD (Test-Driven Development) prefer clear separation of concerns which implies persistence ignorance. The main advantage is that applications will follow a conceptual model that is independent of the physical/storage model Example: Create POCO entity for Category and Product public class Category { public int CategoryID { get; set; } public string CategoryName { get; set; } public string Description { get; set; } public List<Product> Products { get; set; } } public class Product { public int ProductID { get; set; } public string ProductName { get; set; } public Category Category { get; set; } } In this example, We have a Category entity which contains properties to define it and also a navigation property List. For this Navigation Property, we have one more entity as Product. What is a Custom Class/DTO? DTO usually refers to Data Transfer Objects. A DTO can be described as a  collection of properties which has no behavior of its own. It is a lightweight container used for moving data between layers. It can be simplified as a representation of entities in the application so that if at anytime ,Entity got changed or modified, there will be  no effect on application as the DTO will not change. A DTO’s only purpose is to transfer state, and should have no behavior. data will get exchanged between the layers with the help of containers like DTOs and application will be free from any underlying complexity of the related entity. Example: EmployeeDTO public EmployeeDTO() { EmployeeId = Int_NullValue; Name = String_NullValue; Email = String_NullValue; Address = String_NullValue; City = String_NullValue; State = String_NullValue; ZipCode = Int_NullValue; } What is Entity? As entity...

Read More
Try one ORM: Entity Framework
Dec30

Try one ORM: Entity Framework

As promised in the last article, We are going to share our experience of Entity Framework Ver 4.1. First of all, we have to add and configure Entity Framework in visual studio. We are going to use “NuGet” manager. Steps to check whether “NuGet” manager is already installed. 1)Open Visual Studio 2010, Go to Tools menu and click on Library Package Manager. If NuGet is not installed,Follow the below steps to install it through Extension Manager. 1)Open Visual Studio 2010, Go to Tools menu and click on Extension Manager. 2) On left hand side, you will find Online Gallery, Click on it. 3) Download NuGet Package Manager and install it. What is NuGet Package Manager? From codeplex “NuGet is a free, open source developer focused package management system for the .NET platform intent on simplifying the process of incorporating third-party libraries into a .NET application during development.” We use several third party libraries in the project development and have to each location for the library and integrate the library in our project which is quite a painful process in the long run. NuGet heals the process by introducing a package management which streamline the process of sharing and using open source libraries. Steps to add Entity Framework: 1)Go to Project,Click on Manage NuGet Packages. 2) Search for Entity Framework and Install. 3) Our recommendation is to download POCO also. Open Extension Manager again and Go to online Gallery, Here search for EF. 2)Download and Install EF 4.x POCO Entity generator for c# We will provide a more detailed article for POCO sometime in future as it can’t be covered in one or two lines. To see the results of successful installation, Add new item to the project and see Entity Data Model Template in the window. Later, we will use these models to demonstrate “Model First Approach” and “Code First Approach”....

Read More