Mapping Data Types and Functions
Developers can use the ADO.NET Entity Framework to create data access applications by programming against a conceptual application model instead of programming directly against a relational storage schema.
Type Mapping for Database First
In a Database First model, the data provider uses a store-centric type mapping scheme, in which the PSQL (store) type influences the EDM type used when the model is generated.
Mapping PSQL Types to EDM Types shows PSQL types are mapped to primitive types used in a Database First model. Some PSQL data types can map to several different EDM types; the default values are shown in italics.
The columns are defined as follows:
 
Type Mapping for Model First
Mapping EDM Types to PSQL Types shows the model-centric type mapping, where the EDM Simple Types influences the PSQL (store) type used when the database is created. The columns are defined as follows:
 
Type Mapping for Code First
Mapping CLR Types to PSQL Data Types in a Code First Model shows the model-centric type mapping, where the CLR type influences the PSQL (store) type used when the database is created. Some CLR types can map to several different PSQL types; the default values are shown in italics. ).
The columns are defined as follows:
 
1 In the Code First workflow, if the length of the string field in an entity is not specified, the data provider sets the default length to 2048 and 4096 bytes for unicode and non-unicode types respectively. However, if the length of the string field is set to a maximum allowed limit, that is 4000 bytes for unicode types and 8000 bytes for non-unicode types, the data provider resets it to 2048 bytes and 4096 bytes respectively. For all the other scenarios where the length of the string field is specified, the data provider uses the specified length.
Mapping EDM Canonical Functions to PSQL Functions
The ADO.NET Entity Framework translates the Entity Data Model (EDM) canonical functions to the corresponding data source functionality for the ADO.NET Entity Framework Data Provider for PSQL. The function invocations are expressed in a common form across data sources.
Because these canonical functions are independent of data sources, argument and return types of canonical functions are defined in terms of types in the EDM. When an Entity SQL query uses canonical functions, the appropriate function is called at the data source.
Both null-input behavior and error conditions are explicitly specified for all canonical functions. However, the ADO.NET Entity Framework does not enforce this behavior. Further details are available at: http://msdn.microsoft.com/en-us/library/bb738626.aspx
Aggregate Canonical Functions
Table 13 describes the mapping of EDM aggregate canonical functions to PSQL functions.
 
Avg(expression)
avg(expression)
BigCount(expression)
count(expression)
Count(expression)
count(expression)
Max(expression)
max(expression)
Min(expression)
min(expression)
StDev(expression)
stdev(expression)
StDevP(expression)
stdevp(expression)
Sum(expression)
sum(expression)
Var(expression)
var(expression)
VarP(expression)
varp(expression)
Math Canonical Functions
Table 14 describes the mapping of EDM math canonical functions to PSQL functions used to process columns that contain only decimal and integer values.
For more information, refer to the Numeric Functions.
 
 
Abs(value)
abs(value)
Ceiling(value)
ceiling(value)
Floor(value)
floor(value)
Round(value)
round(numeric_expression1, integer_expression2)
Date and Time Canonical Functions
Table 15 describes the mapping of EDM date and time canonical functions to PSQL functions that generate, process, and manipulate data that consists of data types such as DATE and TIME.
 
1 Requires PSQL v11.30 Update 4 (May 2013)
Bitwise Canonical Functions
Table 16 describes the mapping of EDM bitwise canonical functions to PSQL functions.
 
BitWiseAnd (value1, value2)
bit_and (value1, value2)
BitWiseOr (value1, value2)
BitWiseXor (value1, value2)
String Canonical Functions
Table 17 describes the mapping of EDM string canonical functions to PSQL functions.
 
Concat(string1, string2)
concat(string1, string2)
Contains(string, target)
contains(string, target)
EndsWith(string, target)
endswith(string, target)
IndexOf(target, string2)
instr(target, string2)
Left(string1, length)
left(string1, length)
Length(string)
length(string)
LTrim(string)
ltrim(string)
Trim(string)
Replace(string1, string2, string3)
replace(string1, string2, string3)
Reverse(string)
reverse(string)
RTrim(string)
rtrim(string)
StartsWith(string, target)
startswith(string, target)
Substring(string, start, length)
ToLower(string)
lower(string)
ToUpper(string)
upper(string)
Other Canonical Functions
Table 18 describes the mapping of other canonical functions to PSQL functions.