Thursday, December 06, 2007 10:57 AM
by
dpblogs
Breaking Changes- Entity Framework Beta 3
EDM Changes
1. CommandText attribute on Function element in SSDL schema has been changed to a child Element.
Mitigation
If you used the CommandText attribute on Function elements, change it to a Child Element.
Beta 2 Code
<Function Name="InsertProduct" IsComposable="false" CommandText="Insert Products ...">
Beta 3 Code
<Function Name="InsertProduct" IsComposable="false" > <CommandText>Insert Products ...</CommandText>
2. Changed all Enumeration values in Schema Files to have Pascal Casing so that they are consistent.
Mitigation
Change the SchemaFiles to reflect the new values.
Csdl Changes
|
Area |
Beta 2 |
Beta 3 |
|
DateTimeKind |
UTC |
Utc |
|
Mode |
in |
In |
|
Mode |
out |
Out |
|
Mode |
inout |
InOut |
|
ConcurrencyMode |
none |
None |
|
ConcurrencyMode |
fixed |
Fixed |
|
MaxLength |
max |
Max |
Ssdl Changes
|
Area |
Beta 2 |
Beta 3 |
|
DateTimeKind |
UTC |
Utc |
|
Mode |
in |
In |
|
Mode |
out |
Out |
|
Mode |
inout |
InOut |
|
StoreGeneratedPattern |
none |
None |
|
StoreGeneratedPattern |
identity |
Identity |
|
StoreGeneratedPattern |
computed |
Computed |
|
MaxLength |
max |
Max |
ProviderManifest Changes
|
Area |
Beta 2 |
Beta 3 |
|
Mode |
in |
In |
|
Mode |
out |
Out |
|
Mode |
inout |
InOut |
CSMapping Changes
|
Area |
Beta 2 |
Beta 3 |
|
Version |
original |
Original |
|
Version |
current |
Current |
CodeGeneration Changes
|
Area |
Beta 2 |
Beta 3 |
|
Access |
public |
Public |
|
Access |
internal |
Internal |
|
Access |
private |
Private |
|
Getter/Setter |
public |
Public |
|
Getter/Setter |
internal |
Internal |
3. GetMappedPrimitiveType method on MetadataWorkspace and ItemCollection class has been removed.
Beta 2 Code
PrimitiveTypeKind edmType = ((PrimitiveType)
sourceProperty.Type.EdmType).PrimitiveTypeKind;
PrimitiveType sqlType = workspace.GetMappedPrimitiveType(edmType,
DataSpace.SSpace);
Beta 3 Code
TypeUsage edmType = sourceProperty.TypeUsage;
EntityConnection connection = context.Connection as EntityConnection;
DbProviderServices services = DbProviderServices.CreateProviderServices
(connection.StoreConnection);
DbProviderManifest manifest = services.GetProviderManifest
(connection.StoreConnection);
TypeUsage sqlType = manifest.GetStoreType(edmType);
4. StoreItemCollection that is Constructed over SqlConnection needs an Open or Openable connection. Previously a non-null SqlConnection would have worked even if it could not be opened.
Mitigation
If you were previously using a SqlConnection that was not openable and you don't prefer the provider to open a connection, you would need to use a new Constructor added to the StoreItemCollection that takes in DBProviderFactory instead of DBConnection. This would only work if the SSDL file passed into the constructor had a ProviderManifestToken attribute added to the Schema element.
Beta 2 Code
storeItemCollection = new StoreItemCollection( new SqlConnection(), ssdlFilePath);
Beta 3 Code
storeItemCollection = new StoreItemCollection(SqlClientFactory.Instance, ssdlFilePath);
5. Unsigned types have been removed from EDM/CSDL type system.
Mitigation
No mitigation for this.
Entity Services Changes
6. Obtaining the native SQL generated for a given command has changed. EntityCommand - DbProviderServices.CreateCommandDefinition, ObjectQuery.CreateCommandTree() and DbProviderServices.CreateCommandDefinition are no longer available
Mitigation
There is a new, simpler, pattern. Use EntityCommand.ToTraceString() or ObjectQuery.ToTraceString().
Beta 2 Code
string esql = "SELECT VALUE product \n" +
"FROM Northwind.Products AS product\n" +
"WHERE LEFT(product.ProductName, 1) = 'C' \n" +
"ORDER BY product.ProductName";
EntityCommand productsCmd = connection.CreateCommand();
productsCmd.CommandText = esql;
connection.Open();
productsCmd .Prepare();
IServiceProvider serviceProvider = (IServiceProvider)EntityProviderFactory.Instance;
DbProviderServices providerServices = (DbProviderServices)serviceProvider.GetService(typeof(DbProviderServices));
EntityCommandDefinition commandDefinition = (EntityCommandDefinition)providerServices.CreateCommandDefinition(productsCmd );
foreach (string commandText in commandDefinition.MappedCommands)
{
Console.WriteLine(commandText);
}
Beta 3 Code
// For EntityCommand
string esql = "SELECT VALUE product \n" +
"FROM Northwind.Products AS product\n" +
"WHERE LEFT(product.ProductName, 1) = 'C' \n" +
"ORDER BY product.ProductName";
EntityCommand productsCmd = connection.CreateCommand();
productsCmd.CommandText = esql;
connection.Open();
Console.WriteLine(productsCmd.ToTraceString());
// For ObjectQuery
ObjectQuery<Northwind.Product> products = northwind.Products
.Where("LEFT(it.ProductName, 1) = 'C'")
.OrderBy("it.ProductName");
northwind.Connection.Open();
Console.WriteLine(products.ToTraceString());
7. Canonical function Edm.Length() ignores trailing white space when connected to SQL Server (any version).
Mitigation
Previously Edm.Length() was trying to include trailing spaces. Starting with Beta 3 it maps directly to SqlServer.Len() which ignores trailing spaces. Consider trimming trailing white space on literals and properties before sending them down the pipeline.
Beta 2 Code
Edm.Length('abc ')
-- T-SQL: LEN('abc ' + '.') - LEN('.')
-- Returns: 4
Beta 3 Code
Edm.Length('abc ')
-- T-SQL: LEN('abc ')
-- Returns: 3
LINQ to Entities Changes
8.