MathTeacherSaidFunctionsAlwaysReturnValue - adding support for writing function return values

(needed to enable writing TVFs returned by the provider when reverse engineering db)
Update SsdlSerializer to validate its model when serializing (and to emit
error events if errors are found)
MappingAPIWantsMorePublicity
 - making StructuralType.AddProperty method public
 - removing the unused parameter from the StorageEndPropertyMapping ctor - we would always pass null there anyways
OneProviderToRuleThemAll (Allow single registration of a DbProviderServices to resolve additional services)

This change makes DbProviderServices implement IDbDependencyResolver so that when a provider is registered either in DbConfiguration or in the config file it can be used to resolve additional services. For example, instead of registering the Migrations SQL Generator separately, the registered DbProviderServices can now override GetService to return the SQL generator.

Not all providers will need to resolve all potentially provider-dependent services since the default service implementation may work just fine. For example, some providers may need to create a new implementation of IContextKeyFactory, while others (including both SQL Server and SQL Compact) can just use the default. The mechanism is also not limited to services that are known to be provider-specific, thereby giving providers greater flexibility in configuring services where some detail doesn't work well for that provider.

The implementation here depends on a new concept of a "secondary resolver". This is a dependency resolver that sits in the chain as normal, but when added is placed near the bottom of the chain (just above the root resolvers) such that it can resolve services that have not already been resolved without getting in the way of application-specific configuration. In effect, it allows code from outside of EF to change root resolvers.

Several things still remain to be done here:
- Update the PowerShell commands to make the most-recently added provider the default such that it will get a chance to resolve non-provider-specific services before other providers.
- Consider whether or not the registration of the default connection factory in the config is still required.
- Consider changes to DbProviderServices to make resolution of execution strategies happen only through this general mechanism rather than using the specific methods that were previously added.
- Potentially change spatial resolution to resolve provider-specific spatial services before global spatial services.
- Updating provider documentation to reflect these changes
Changes to EDM serialization to write comments that include error information from metadata and invalid types.
Build break fix against .NET 4.0. Older compiler is not able to infer type arguments from usage. Specifying them explicitly.
GoingOldSkool (Replace IHistoryContextFactory interface with HistoryContextFactory delegate)

IHistoryContextFactory existed as a way to register a service that could create customized HistoryContext instances. However, it was a pain to have to create a class for this when just a delegate would be fine. The problems with using Func<DbConnection, bool, string> is that it is not very helpful for Intellisense or very specific/useful for defining a service. So instead this change introduces a delegate type that provides help and is a reasonable type to define a service for.
Moving try/catch logic from DatabaseOperations.Exists to ObjectContext.DatabaseExists to make the behavior consistent.
Added more tests for database operations with auto-named attached databases and restricted permissions to the master database.
Also catching "The system cannot find the file specified" when deleting an auto-named attached database.

Work item: 1013
Issue 879 - move SqlFunctions and SqlSpatialFunctions to SqlServer
assembly and change namespace
Moving aruba model out of transition project. CR: BriceLam
Removed unparsed '\t' from error message in resource file
CSDLMeansCSpace - fixing a model validation rule

ValidateReferentialConstraint rule is checking whether the properties on the dependent side
are key properties for IAs. According to the comment this rule should be enforced on CSpace
models. The check was missing and after we enabled validation for SSpace models the rule was
enforced also on SSpace models. This breaks the designer since the schema views contain models
that trigger this condition. Also note that this condition could only be triggered for v1
models but all schema views (even for reverse engineering v3 concepts) are v1.
ExceptionToTheRule - relaxing edm model validation

- Some of the naming validation rules must not be enforced on row types since names for row types are automatically generated by EF and therefore are in "transient" namespace. In addition they include all the names of the properties (what makes the name too long) of the row type with fully qualified type names (what makes the name contain '.'). These rules had to be relaxed to allow writing SSDL for TVFs
- The designer may pass invalid types to the SsdlSerializer. They have a metadata property indicating that the type is invalid and therefore should be written as comment. The SsdlSerializer could handle writing invalid types but after we turned on validation on SSpace models validation would not allow writing anything. Therefore we must not report validation errors for invalid types.
- Reverting making StructuralTypeMapping.AddProperty public - the designer is using StorageAssociationSetMapping.AddProperty to achieve the same and this method was already public
TyingUpSomeNedSherrins (Completing several outstanding changes related to grouping providers)

The changes are:
- Update spatial services resolution to use provider-specific resolution first and only use the global provider when provider-specific resolution is not possible.
- Remove DbProviderServices virtual method for execution strategy since this is now obtained by GetService
- Obsolete virtual method spatial services for same reason
- Remove default provider flag based on design meeting decision and just use resolver ordering
- Remove config file registration for global spatial provider and migrations sql generator
- Ensure provider moves to end of chaing when Add-EFProvider is called
- Remove bool parameter from HistoryContextFactory delegate
adding _ to private fields in transaction tests
Updating EdmxSerializer to accept V1 version
Merge branch 'master' of https://git01.codeplex.com/entityframework
Enabling adding MetadataProperties to EntityContainers using the public Create factory method.
Needed for the designer so that it can add LazyLoading attribute.
WonderboltsAcademy (Fix for build/test perf regression)

OneProviderToRuleThemAll caused the amount of time to run build.cmd to increase substantially. The problem was (as suspected) the provider loading code. The fix is two-fold. First, the expensive Reflection code to create the provider instances has been moved into the AppConfig class and cached there so that for a given config it only happens once. Second, when Migrations is running on behalf of a DbContext it needs to make sure that the correct configuration is used, which makes use of the push/pop configuration functionality. But if Migrations is being used with the default config for the app domain and for an assembly that is already known about, then there is no need to push a new configuration and so this is now avoided.
Migrations: First part of enabling sproc scaffolding in migrations/initializers.

- Adds DML SQL function body generation to SQL provider.
- Updates dynamic DML SQL generator to support parameterized CQTs and local variable bindings.
- Adds a new component: ModificationCommandTreeGenerator that leverages the new interception infrastructure to produce dynamic modification command trees for entities. It works by using the OSpace model to fake the state manager into getting the update pipeline to produce the required dynamic CQTs.
- Adds a new component: DynamicToFunctionModificationCommandConverter that can convert a sequence of dynamic CQTs into a sequence of function body CQTs. It does this by rebinding constant/is null/null expressions to sproc parameters and by also introducing local variable parameter sentinels enabling subsequent local variable generation for store-generated value propagation.
- Updated the differ to detect added/removed modification sprocs.
- Added new migrations operations representing added/removed modification sprocs.
- When scripting, sprocs must be executed in their own batch - added the concept of a batch terminator to MigrationStatement and updated the scripting decorator.
- Added MapToTable analog of MapToStoredProcedures (currently internal) which allows forcing a DbModelBuilder to generated a model without any sprocs.

FIXES: Two bugs were addressed as part of this change:

1) NEW: ModelConfiguration: Ensure that all sproc metadata is generated before applying any explicit sproc configuration.
2) #676: Code First: TPT specify a different name for the primary key column in each table. This already kind of worked but would fail in the case where IAs were present somewhere in the hierarchy. I'm leaving the bug open as I have only fixed the IA issue and am not sure whether it works everywhere else. We need to do further investigation here.