diff --git a/src/EntityFramework.SqlServer/SqlProviderServices.cs b/src/EntityFramework.SqlServer/SqlProviderServices.cs index 8d62ea7f7c..c92a22a77c 100644 --- a/src/EntityFramework.SqlServer/SqlProviderServices.cs +++ b/src/EntityFramework.SqlServer/SqlProviderServices.cs @@ -1107,7 +1107,31 @@ internal static SqlVersion CreateDatabaseFromScript(int? commandTimeout, DbConne /// Execution timeout for any commands needed to determine the existence of the database. /// The collection of all store items from the model. This parameter is no longer used for determining database existence. /// True if the provider can deduce the database only based on the connection. - protected override bool DbDatabaseExists(DbConnection connection, int? commandTimeout, StoreItemCollection storeItemCollection) + protected override bool DbDatabaseExists( + DbConnection connection, int? commandTimeout, StoreItemCollection storeItemCollection) + { + return DbDatabaseExists(connection, commandTimeout, new Lazy(() => storeItemCollection)); + } + + /// + /// Determines whether the database for the given connection exists. + /// There are three cases: + /// 1. Initial Catalog = X, AttachDBFilename = null: (SELECT Count(*) FROM sys.databases WHERE [name]= X) > 0 + /// 2. Initial Catalog = X, AttachDBFilename = F: if (SELECT Count(*) FROM sys.databases WHERE [name]= X) > true, + /// if not, try to open the connection and then return (SELECT Count(*) FROM sys.databases WHERE [name]= X) > 0 + /// 3. Initial Catalog = null, AttachDBFilename = F: Try to open the connection. If that succeeds the result is true, otherwise + /// if the there are no databases corresponding to the given file return false, otherwise throw. + /// Note: We open the connection to cover the scenario when the mdf exists, but is not attached. + /// Given that opening the connection would auto-attach it, it would not be appropriate to return false in this case. + /// Also note that checking for the existence of the file does not work for a remote server. (Dev11 #290487) + /// For further details on the behavior when AttachDBFilename is specified see Dev10# 188936 + /// + /// Connection to a database whose existence is checked by this method. + /// Execution timeout for any commands needed to determine the existence of the database. + /// The collection of all store items from the model. This parameter is no longer used for determining database existence. + /// True if the provider can deduce the database only based on the connection. + protected override bool DbDatabaseExists( + DbConnection connection, int? commandTimeout, Lazy storeItemCollection) { Check.NotNull(connection, "connection"); Check.NotNull(storeItemCollection, "storeItemCollection"); diff --git a/src/EntityFramework.SqlServerCompact/SqlCeProviderServices.cs b/src/EntityFramework.SqlServerCompact/SqlCeProviderServices.cs index 20c92e7c7e..66086202e0 100644 --- a/src/EntityFramework.SqlServerCompact/SqlCeProviderServices.cs +++ b/src/EntityFramework.SqlServerCompact/SqlCeProviderServices.cs @@ -92,6 +92,20 @@ protected override string DbCreateDatabaseScript(string providerManifestToken, S /// Item Collection. /// Bool indicating whether database exists or not. protected override bool DbDatabaseExists(DbConnection connection, int? timeOut, StoreItemCollection storeItemCollection) + { + return DbDatabaseExists(connection, timeOut, new Lazy(() => storeItemCollection)); + } + + /// + /// API for checkin whether database exists or not. + /// This will internally only check whether the file that the connection points to exists or not. + /// Note: In case of SQLCE, timeout and storeItemCollection parameters are ignored. + /// + /// Connection + /// Timeout for internal commands. + /// Item Collection. + /// Bool indicating whether database exists or not. + protected override bool DbDatabaseExists(DbConnection connection, int? timeOut, Lazy storeItemCollection) { Check.NotNull(connection, "connection"); Check.NotNull(storeItemCollection, "storeItemCollection"); diff --git a/src/EntityFramework/Core/Common/DbProviderServices.cs b/src/EntityFramework/Core/Common/DbProviderServices.cs index f7c051187b..60cd341410 100644 --- a/src/EntityFramework/Core/Common/DbProviderServices.cs +++ b/src/EntityFramework/Core/Common/DbProviderServices.cs @@ -639,13 +639,33 @@ public bool DatabaseExists(DbConnection connection, int? commandTimeout, StoreIt } } + /// Returns a value indicating whether a given database exists on the server. + /// True if the provider can deduce the database only based on the connection. + /// Connection to a database whose existence is checked by this method. + /// Execution timeout for any commands needed to determine the existence of the database. + /// The collection of all store items from the model. This parameter is no longer used for determining database existence. + public bool DatabaseExists( + DbConnection connection, + int? commandTimeout, + Lazy storeItemCollection) + { + Check.NotNull(connection, "connection"); + Check.NotNull(storeItemCollection, "storeItemCollection"); + + using (new TransactionScope(TransactionScopeOption.Suppress)) + { + return DbDatabaseExists(connection, commandTimeout, storeItemCollection); + } + } + /// Returns a value indicating whether a given database exists on the server. /// True if the provider can deduce the database only based on the connection. /// Connection to a database whose existence is checked by this method. /// Execution timeout for any commands needed to determine the existence of the database. /// The collection of all store items from the model. This parameter is no longer used for determining database existence. protected virtual bool DbDatabaseExists( - DbConnection connection, int? commandTimeout, + DbConnection connection, + int? commandTimeout, StoreItemCollection storeItemCollection) { Check.NotNull(connection, "connection"); @@ -654,6 +674,23 @@ protected virtual bool DbDatabaseExists( throw new ProviderIncompatibleException(Strings.ProviderDoesNotSupportDatabaseExists); } + /// Returns a value indicating whether a given database exists on the server. + /// True if the provider can deduce the database only based on the connection. + /// Connection to a database whose existence is checked by this method. + /// Execution timeout for any commands needed to determine the existence of the database. + /// The collection of all store items from the model. This parameter is no longer used for determining database existence. + /// Override this method to avoid creating the store item collection if it is not needed. The default implementation evaluates the Lazy and calls the other overload of this method. + protected virtual bool DbDatabaseExists( + DbConnection connection, + int? commandTimeout, + Lazy storeItemCollection) + { + Check.NotNull(connection, "connection"); + Check.NotNull(storeItemCollection, "storeItemCollection"); + + return DbDatabaseExists(connection, commandTimeout, storeItemCollection.Value); + } + /// Deletes the specified database. /// Connection to an existing database that needs to be deleted. /// Execution timeout for any commands needed to delete the database. diff --git a/src/EntityFramework/Database.cs b/src/EntityFramework/Database.cs index e837b5b7cd..0567c44112 100644 --- a/src/EntityFramework/Database.cs +++ b/src/EntityFramework/Database.cs @@ -5,6 +5,7 @@ namespace System.Data.Entity using System.ComponentModel; using System.Data.Common; using System.Data.Entity.Core.EntityClient; + using System.Data.Entity.Core.Metadata.Edm; using System.Data.Entity.Core.Objects; using System.Data.Entity.Infrastructure; using System.Data.Entity.Infrastructure.DependencyResolution; @@ -202,7 +203,10 @@ internal void Create(DatabaseExistenceState existenceState) { if (existenceState == DatabaseExistenceState.Unknown) { - if (_internalContext.DatabaseOperations.Exists(_internalContext.Connection, _internalContext.CommandTimeout)) + if (_internalContext.DatabaseOperations.Exists( + _internalContext.Connection, + _internalContext.CommandTimeout, + new Lazy(CreateStoreItemCollection))) { var interceptionContext = new DbInterceptionContext(); interceptionContext = interceptionContext.WithDbContext(_internalContext.Owner); @@ -226,7 +230,10 @@ internal void Create(DatabaseExistenceState existenceState) /// True if the database did not exist and was created; false otherwise. public bool CreateIfNotExists() { - if (_internalContext.DatabaseOperations.Exists(_internalContext.Connection, _internalContext.CommandTimeout)) + if (_internalContext.DatabaseOperations.Exists( + _internalContext.Connection, + _internalContext.CommandTimeout, + new Lazy(CreateStoreItemCollection))) { return false; } @@ -244,7 +251,10 @@ public bool CreateIfNotExists() /// True if the database exists; false otherwise. public bool Exists() { - return _internalContext.DatabaseOperations.Exists(_internalContext.Connection, _internalContext.CommandTimeout); + return _internalContext.DatabaseOperations.Exists( + _internalContext.Connection, + _internalContext.CommandTimeout, + new Lazy(CreateStoreItemCollection)); } /// @@ -257,7 +267,10 @@ public bool Exists() /// True if the database did exist and was deleted; false otherwise. public bool Delete() { - if (!_internalContext.DatabaseOperations.Exists(_internalContext.Connection, _internalContext.CommandTimeout)) + if (!_internalContext.DatabaseOperations.Exists( + _internalContext.Connection, + _internalContext.CommandTimeout, + new Lazy(CreateStoreItemCollection))) { return false; } @@ -289,7 +302,10 @@ public static bool Exists(string nameOrConnectionString) using (var connection = new LazyInternalConnection(nameOrConnectionString)) { - return new DatabaseOperations().Exists(connection.Connection, null); + return new DatabaseOperations().Exists( + connection.Connection, + null, + new Lazy(() => new StoreItemCollection())); } } @@ -329,7 +345,10 @@ public static bool Exists(DbConnection existingConnection) { Check.NotNull(existingConnection, "existingConnection"); - return new DatabaseOperations().Exists(existingConnection, null); + return new DatabaseOperations().Exists( + existingConnection, + null, + new Lazy(() => new StoreItemCollection())); } /// @@ -692,6 +711,15 @@ public override int GetHashCode() #endregion + private StoreItemCollection CreateStoreItemCollection() + { + using (var clonedObjectContext = _internalContext.CreateObjectContextForDdlOps()) + { + var entityConnection = ((EntityConnection)clonedObjectContext.ObjectContext.Connection); + return (StoreItemCollection)entityConnection.GetMetadataWorkspace().GetItemCollection(DataSpace.SSpace); + } + } + /// /// Gets or sets the timeout value, in seconds, for all context operations. /// The default value is null, where null indicates that the default value of the underlying diff --git a/src/EntityFramework/Internal/DatabaseOperations.cs b/src/EntityFramework/Internal/DatabaseOperations.cs index 937a08583c..c702b5c358 100644 --- a/src/EntityFramework/Internal/DatabaseOperations.cs +++ b/src/EntityFramework/Internal/DatabaseOperations.cs @@ -39,7 +39,7 @@ public virtual bool Create(ObjectContext objectContext) // having an ObjectContext. // [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - public virtual bool Exists(DbConnection connection, int? commandTimeout) + public virtual bool Exists(DbConnection connection, int? commandTimeout, Lazy storeItemCollection) { DebugCheck.NotNull(connection); @@ -51,7 +51,7 @@ public virtual bool Exists(DbConnection connection, int? commandTimeout) try { return DbProviderServices.GetProviderServices(connection) - .DatabaseExists(connection, commandTimeout, new StoreItemCollection()); + .DatabaseExists(connection, commandTimeout, storeItemCollection); } catch { diff --git a/src/EntityFramework/Internal/DatabaseTableChecker.cs b/src/EntityFramework/Internal/DatabaseTableChecker.cs index d4b9935526..26de636491 100644 --- a/src/EntityFramework/Internal/DatabaseTableChecker.cs +++ b/src/EntityFramework/Internal/DatabaseTableChecker.cs @@ -21,7 +21,10 @@ internal class DatabaseTableChecker [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")] public DatabaseExistenceState AnyModelTableExists(InternalContext internalContext) { - var exists = internalContext.DatabaseOperations.Exists(internalContext.Connection, internalContext.CommandTimeout); + var exists = internalContext.DatabaseOperations.Exists( + internalContext.Connection, + internalContext.CommandTimeout, + new Lazy(() => CreateStoreItemCollection(internalContext))); if (!exists) { @@ -87,6 +90,15 @@ public DatabaseExistenceState AnyModelTableExists(InternalContext internalContex } } + private static StoreItemCollection CreateStoreItemCollection(InternalContext internalContext) + { + using (var clonedObjectContext = internalContext.CreateObjectContextForDdlOps()) + { + var entityConnection = ((EntityConnection)clonedObjectContext.ObjectContext.Connection); + return (StoreItemCollection)entityConnection.GetMetadataWorkspace().GetItemCollection(DataSpace.SSpace); + } + } + public virtual bool QueryForTableExistence( IPseudoProvider provider, ClonedObjectContext clonedObjectContext, List modelTables) { diff --git a/test/EntityFramework/FunctionalTests/WrappingProvider/WrappingEfProvider.cs b/test/EntityFramework/FunctionalTests/WrappingProvider/WrappingEfProvider.cs index 5693174bc8..82313d970d 100644 --- a/test/EntityFramework/FunctionalTests/WrappingProvider/WrappingEfProvider.cs +++ b/test/EntityFramework/FunctionalTests/WrappingProvider/WrappingEfProvider.cs @@ -8,7 +8,6 @@ namespace System.Data.Entity.WrappingProvider using System.Data.Entity.Core.Metadata.Edm; using System.Data.Entity.Migrations.Sql; using System.Data.Entity.Functionals.Utilities; - using System.Reflection; public class WrappingEfProvider : DbProviderServices where TAdoNetBase : DbProviderFactory @@ -46,10 +45,10 @@ protected override void DbCreateDatabase(DbConnection connection, int? commandTi _baseServices.CreateDatabase(((WrappingConnection)connection).BaseConnection, commandTimeout, storeItemCollection); } - protected override bool DbDatabaseExists(DbConnection connection, int? commandTimeout, StoreItemCollection storeItemCollection) + protected override bool DbDatabaseExists(DbConnection connection, int? commandTimeout, Lazy storeItemCollection) { WrappingAdoNetProvider.Instance.Log.Add( - new LogItem("DbDatabaseExists", connection, new object[] { commandTimeout, storeItemCollection })); + new LogItem("DbDatabaseExists", connection, new object[] { commandTimeout, storeItemCollection.Value })); return _baseServices.DatabaseExists( ((WrappingConnection)connection).BaseConnection, commandTimeout, storeItemCollection); diff --git a/test/EntityFramework/FunctionalTests/WrappingProvider/WrappingProviderTests.cs b/test/EntityFramework/FunctionalTests/WrappingProvider/WrappingProviderTests.cs index 1182615afb..db2371a6c4 100644 --- a/test/EntityFramework/FunctionalTests/WrappingProvider/WrappingProviderTests.cs +++ b/test/EntityFramework/FunctionalTests/WrappingProvider/WrappingProviderTests.cs @@ -5,6 +5,7 @@ namespace System.Data.Entity.WrappingProvider using System.Collections.Generic; using System.Data.Common; using System.Data.Entity.Core.Common; + using System.Data.Entity.Core.Metadata.Edm; using System.Data.Entity.Functionals.Utilities; using System.Data.Entity.Infrastructure; using System.Data.Entity.Infrastructure.DependencyResolution; @@ -191,6 +192,28 @@ public void Simple_query_and_update_works_with_wrapping_provider_setup_at_EF_lev Assert.Contains("Generate", methods); } + [Fact] // CodePlex 2320 + [UseDefaultExecutionStrategy] + public void Model_is_available_in_DatabaseExists() + { + WrappingAdoNetProvider.WrapProviders(); + + var log = WrappingAdoNetProvider.Instance.Log; + log.Clear(); + + using (var context = new EfLevelBlogContext()) + { + context.Database.Exists(); + } + + var rawDetails = (object[])log.Where(i => i.Method == "DbDatabaseExists").Select(i => i.RawDetails).Single(); + var itemCollection = (StoreItemCollection)rawDetails[1]; + + Assert.Equal( + new[] { "Blog", "Post" }, + itemCollection.OfType().Select(e => e.Name).OrderBy(n => n).ToArray()); + } + public class Blog { public int Id { get; set; } diff --git a/test/EntityFramework/UnitTests/DatabaseInitializerTests.cs b/test/EntityFramework/UnitTests/DatabaseInitializerTests.cs index dc226da6aa..b10bd6feda 100644 --- a/test/EntityFramework/UnitTests/DatabaseInitializerTests.cs +++ b/test/EntityFramework/UnitTests/DatabaseInitializerTests.cs @@ -3,6 +3,7 @@ namespace System.Data.Entity { using System.Data.Common; + using System.Data.Entity.Core.Metadata.Edm; using Moq; using System; using System.Data.Entity.Core.Objects; @@ -821,7 +822,7 @@ public void Database_Create_calls_CreateDatabase_if_database_does_not_exist() var mockContext = new Mock>(); mockContext.Setup(m => m.DatabaseOperations).Returns(mockOperations.Object); mockContext.Setup(m => m.CreateObjectContextForDdlOps()).Returns(new Mock().Object); - mockOperations.Setup(m => m.Exists(null, It.IsAny())).Returns(false); + mockOperations.Setup(m => m.Exists(null, It.IsAny(), It.IsAny>())).Returns(false); mockContext.Object.Owner.Database.Create(); @@ -835,7 +836,7 @@ public void Database_CreateIfNotExists_calls_CreateDatabase_if_database_does_not var mockContext = new Mock>(); mockContext.Setup(m => m.DatabaseOperations).Returns(mockOperations.Object); mockContext.Setup(m => m.CreateObjectContextForDdlOps()).Returns(new Mock().Object); - mockOperations.Setup(m => m.Exists(null, It.IsAny())).Returns(false); + mockOperations.Setup(m => m.Exists(null, It.IsAny(), It.IsAny>())).Returns(false); mockContext.Object.Owner.Database.CreateIfNotExists(); @@ -849,7 +850,7 @@ public void Database_Create_throws_and_does_not_call_CreateDatabase_if_database_ var mockContext = new Mock>() { CallBase = true }; mockContext.Setup(m => m.DatabaseOperations).Returns(mockOperations.Object); mockContext.Setup(m => m.Connection).Returns(new SqlConnection("Database=Foo")); - mockOperations.Setup(m => m.Exists(It.IsAny(), It.IsAny())).Returns(true); + mockOperations.Setup(m => m.Exists(It.IsAny(), It.IsAny(), It.IsAny>())).Returns(true); Assert.Equal( Strings.Database_DatabaseAlreadyExists("Foo"), @@ -865,7 +866,7 @@ public void Database_CreateIfNotExists_does_not_call_CreateDatabase_if_database_ var mockContext = new Mock>(); mockContext.Setup(m => m.DatabaseOperations).Returns(mockOperations.Object); mockContext.Setup(m => m.CreateObjectContextForDdlOps()).Returns(new Mock().Object); - mockOperations.Setup(m => m.Exists(null, It.IsAny())).Returns(true); + mockOperations.Setup(m => m.Exists(null, It.IsAny(), It.IsAny>())).Returns(true); mockContext.Object.Owner.Database.CreateIfNotExists(); diff --git a/test/EntityFramework/UnitTests/Internal/DatabaseTableCheckerTests.cs b/test/EntityFramework/UnitTests/Internal/DatabaseTableCheckerTests.cs index 6039a5862c..7382096e9a 100644 --- a/test/EntityFramework/UnitTests/Internal/DatabaseTableCheckerTests.cs +++ b/test/EntityFramework/UnitTests/Internal/DatabaseTableCheckerTests.cs @@ -28,7 +28,7 @@ public void AnyModelTableExists_uses_ExecutionStrategy() var internalContextMock = new Mock(); var mockOperations = new Mock(); - mockOperations.Setup(m => m.Exists(It.IsAny(), It.IsAny())).Returns(true); + mockOperations.Setup(m => m.Exists(It.IsAny(), It.IsAny(), It.IsAny>())).Returns(true); internalContextMock.Setup(m => m.DatabaseOperations).Returns(mockOperations.Object); var dbCommandMock = new Mock(); @@ -72,7 +72,7 @@ public void AnyModelTableExists_dispatches_to_interceptors() var dbCommandMock = new Mock(); var mockOperations = new Mock(); - mockOperations.Setup(m => m.Exists(It.IsAny(), It.IsAny())).Returns(true); + mockOperations.Setup(m => m.Exists(It.IsAny(), It.IsAny(), It.IsAny>())).Returns(true); internalContextMock.Setup(m => m.DatabaseOperations).Returns(mockOperations.Object); SetupMocksForTableChecking(dbCommandMock, connectionMock, internalContextMock); @@ -101,7 +101,7 @@ public void AnyModelTableExists_dispatches_to_interceptors() public void AnyModelTableExists_returns_DoesNotExist_if_database_does_not_exist() { var mockOperations = new Mock(); - mockOperations.Setup(m => m.Exists(It.IsAny(), It.IsAny())).Returns(false); + mockOperations.Setup(m => m.Exists(It.IsAny(), It.IsAny(), It.IsAny>())).Returns(false); var internalContextMock = new Mock(); internalContextMock.Setup(m => m.DatabaseOperations).Returns(mockOperations.Object); @@ -114,7 +114,7 @@ public void AnyModelTableExists_returns_DoesNotExist_if_database_does_not_exist( public void AnyModelTableExists_returns_Exists_if_database_exists_and_not_Code_First() { var mockOperations = new Mock(); - mockOperations.Setup(m => m.Exists(It.IsAny(), It.IsAny())).Returns(true); + mockOperations.Setup(m => m.Exists(It.IsAny(), It.IsAny(), It.IsAny>())).Returns(true); var internalContextMock = new Mock(); internalContextMock.Setup(m => m.DatabaseOperations).Returns(mockOperations.Object); @@ -127,7 +127,7 @@ public void AnyModelTableExists_returns_Exists_if_database_exists_and_not_Code_F public void AnyModelTableExists_returns_Exists_if_provider_doesnt_support_table_checking() { var mockOperations = new Mock(); - mockOperations.Setup(m => m.Exists(It.IsAny(), It.IsAny())).Returns(true); + mockOperations.Setup(m => m.Exists(It.IsAny(), It.IsAny(), It.IsAny>())).Returns(true); var internalContextMock = new Mock(); internalContextMock.Setup(m => m.DatabaseOperations).Returns(mockOperations.Object); @@ -142,7 +142,7 @@ public void AnyModelTableExists_returns_Exists_if_provider_doesnt_support_table_ public void AnyModelTableExists_returns_Exists_if_model_is_empty() { var mockOperations = new Mock(); - mockOperations.Setup(m => m.Exists(It.IsAny(), It.IsAny())).Returns(true); + mockOperations.Setup(m => m.Exists(It.IsAny(), It.IsAny(), It.IsAny>())).Returns(true); var internalContextMock = new Mock(); internalContextMock.Setup(m => m.DatabaseOperations).Returns(mockOperations.Object); @@ -160,7 +160,7 @@ public void AnyModelTableExists_returns_Exists_if_model_is_empty() public void AnyModelTableExists_returns_Exists_if_any_model_table_exists() { var mockOperations = new Mock(); - mockOperations.Setup(m => m.Exists(It.IsAny(), It.IsAny())).Returns(true); + mockOperations.Setup(m => m.Exists(It.IsAny(), It.IsAny(), It.IsAny>())).Returns(true); var internalContextMock = new Mock(); internalContextMock.Setup(m => m.DatabaseOperations).Returns(mockOperations.Object); @@ -183,7 +183,7 @@ public void AnyModelTableExists_returns_Exists_if_any_model_table_exists() public void AnyModelTableExists_returns_Exists_if_history_table_with_entry_exists() { var mockOperations = new Mock(); - mockOperations.Setup(m => m.Exists(It.IsAny(), It.IsAny())).Returns(true); + mockOperations.Setup(m => m.Exists(It.IsAny(), It.IsAny(), It.IsAny>())).Returns(true); var internalContextMock = new Mock(); internalContextMock.Setup(m => m.DatabaseOperations).Returns(mockOperations.Object); @@ -207,7 +207,7 @@ public void AnyModelTableExists_returns_Exists_if_history_table_with_entry_exist public void AnyModelTableExists_returns_ExistsConsideredEmpty_if_no_tables_and_no_history() { var mockOperations = new Mock(); - mockOperations.Setup(m => m.Exists(It.IsAny(), It.IsAny())).Returns(true); + mockOperations.Setup(m => m.Exists(It.IsAny(), It.IsAny(), It.IsAny>())).Returns(true); var internalContextMock = new Mock(); internalContextMock.Setup(m => m.DatabaseOperations).Returns(mockOperations.Object); diff --git a/test/EntityFramework/UnitTests/SqlServerCompact/SqlCeProviderServicesTests.cs b/test/EntityFramework/UnitTests/SqlServerCompact/SqlCeProviderServicesTests.cs index a41fe67162..be13b3d108 100644 --- a/test/EntityFramework/UnitTests/SqlServerCompact/SqlCeProviderServicesTests.cs +++ b/test/EntityFramework/UnitTests/SqlServerCompact/SqlCeProviderServicesTests.cs @@ -222,7 +222,7 @@ public void DbDatabaseExists_dispatches_to_interceptors() { using (var connection = new SqlCeConnection(ModelHelpers.SimpleCeConnectionString("I.Do.Not.Exist"))) { - Assert.False(SqlCeProviderServices.Instance.DatabaseExists(connection, null, new StoreItemCollection())); + Assert.False(SqlCeProviderServices.Instance.DatabaseExists(connection, null, new Lazy())); } } finally diff --git a/test/EntityFramework/UnitTests/TestHelpers/DatabaseInitializerTracker.cs b/test/EntityFramework/UnitTests/TestHelpers/DatabaseInitializerTracker.cs index f0ab4d1add..16377b239b 100644 --- a/test/EntityFramework/UnitTests/TestHelpers/DatabaseInitializerTracker.cs +++ b/test/EntityFramework/UnitTests/TestHelpers/DatabaseInitializerTracker.cs @@ -3,6 +3,7 @@ namespace System.Data.Entity { using System.Data.Common; + using System.Data.Entity.Core.Metadata.Edm; using System.Data.Entity.Core.Objects; using System.Data.Entity.Internal; using System.Data.Entity.Resources; @@ -59,7 +60,7 @@ internal DatabaseInitializerTracker( }); _mockDatabaseOps - .Setup(d => d.Exists(It.IsAny(), It.IsAny())) + .Setup(d => d.Exists(It.IsAny(), It.IsAny(), It.IsAny>())) .Callback(() => _operations.Append("Exists ")).Returns(_databaseExists); _mockDatabaseOps