public void CreateTransientMetadataWorkspace_creates_workspace_with_provided_store_entity_sets()
        {
            var property =
                EdmProperty.CreatePrimitive(
                    "Id",
                    ProviderManifest.GetStoreTypes().Single(t => t.PrimitiveTypeKind == PrimitiveTypeKind.Int32));

            property.Nullable = false;

            var entityType =
                EntityType.Create("EntityType", "MyModel", DataSpace.SSpace, new[] { "Id" }, new[] { property }, null);

            var entitySet = EntitySet.Create("EntityTypeSet", "dbo", "EntityTypes", null, entityType, null);

            var workspace =
                EntitySetDefiningQueryConverter.CreateTransientMetadataWorkspace(
                    new List <EntitySet> {
                entitySet
            },
                    EntityFrameworkVersion.Version3,
                    "System.Data.SqlClient", "2008", ProviderManifest);

            Assert.NotNull(workspace);
            var storeItemCollection = (StoreItemCollection)workspace.GetItemCollection(DataSpace.SSpace);

            Assert.NotNull(storeItemCollection);
            Assert.Equal(1, storeItemCollection.GetEntityContainer("StoreModelContainer").EntitySets.Count);
            Assert.Equal(
                "EntityTypeSet",
                storeItemCollection.GetEntityContainer("StoreModelContainer").EntitySets.Single().Name);
            Assert.Equal(1, storeItemCollection.GetItems <EntityType>().Count);
            Assert.Equal("EntityType", storeItemCollection.GetItems <EntityType>().Single().Name);
            Assert.NotNull(workspace.GetItemCollection(DataSpace.CSpace));
            Assert.NotNull(workspace.GetItemCollection(DataSpace.CSSpace));
        }
        public void CreateDefiningQuery_creates_query_for_entity_set()
        {
            var property =
                EdmProperty.CreatePrimitive(
                    "Id",
                    ProviderManifest.GetStoreTypes().Single(t => t.PrimitiveTypeKind == PrimitiveTypeKind.Int32));

            property.Nullable = false;

            var entityType =
                EntityType.Create("EntityType", "MyModel", DataSpace.SSpace, new[] { "Id" }, new[] { property }, null);

            var entitySet = EntitySet.Create("EntityTypeSet", "dbo", "EntityTypes", null, entityType, null);

            var workspace =
                EntitySetDefiningQueryConverter.CreateTransientMetadataWorkspace(
                    new List <EntitySet> {
                entitySet
            },
                    EntityFrameworkVersion.Version3,
                    "System.Data.SqlClient", "2008", ProviderManifest);

            Assert.NotNull(EntitySetDefiningQueryConverter.CreateDefiningQuery(entitySet, workspace, SqlProviderServices.Instance));
        }