Friday, June 14, 2013

edmx file orgainzation, Entity Framework

Many times you are in need of making change in edmx file xml instead of simple designer surface. To get better understanding of how edxml's XML is organized, here is a brief overview.

edmx file is composed of three separate entities:

  1. Store details (SSDL Content): Content of this xml section has information about your database, what all tables are included in database, their column names, data types etc.
  2. Conceptual Model (CSDL content): This xml section has information about all properties and entities that you see in designer surface of a model in visual studio. For example you create a property of an entity named "comment" and declare it of "string" type. Now conceptual model will store details as "comment" -> "string". However Store Model will store the same property as "comment"-> "nvarchar2" (assuming comment is <2000 chars) i.e. datatype of property in SQL table.
  3. Conceptual - Store Mapping (C-S Mapping Content): It has information about mapping between the above two described model.
XML Organization:

<edmx: StorageModels>  Store Model (SSDL) details
     -- Entity Type        Table Name for an entity
                -- Property           Column name for a property 
     -- Association        Association table declaration i.e. relation b/w two tables.
                -- Referential Contraint        table's column declaration.

<edmx: ConceptualModels>       Conceptual Model (CSDL) details
     -- EntityContainer
                 -- Entity Set
     -- Entity Type          Class declaration for an entity
                 -- Properties       Property of model class

<edmx: Mappings>            C-S Mapping details
     -- EntityContainerMapping
                 -- Entity Set Mapping            Entity name; table name, class name for entity
                            -- Entity Type Mapping
                                     -- Mapping Fragment
                                                -- Scalar Property             Relation b/w CSDL table property and SSDL table column

No comments:

Post a Comment