I have a desktop application that works with SQL Server CE and EF using a code-first approach, I have large volume of users working with this.
The connection string that I am passing to DbContext class constructor,
@"Data Source=" + Path.Combine("Path to local app data", "Databasename.sdf") + ";Password=mypassword"
But on one of the Windows 7 SP1 (32 bit) machines, I am getting following error:
System.InvalidOperationException: Unable to complete operation. The supplied SqlConnection does not specify an initial catalog or AttachDBFileName.
at System.Data.Entity.SqlServer.SqlProviderServices.GetOrGenerateDatabaseNameAndGetFileNames(SqlConnection sqlConnection, String& databaseName, String& dataFileName, String& logFileName)
at System.Data.Entity.SqlServer.SqlProviderServices.DbCreateDatabase(DbConnection connection, Nullable1 commandTimeout, StoreItemCollection storeItemCollection) at System.Data.Entity.Core.Common.DbProviderServices.CreateDatabase(DbConnection connection, Nullable
1 commandTimeout, StoreItemCollection storeItemCollection)
at System.Data.Entity.Core.Objects.ObjectContext.CreateDatabase()
at System.Data.Entity.Migrations.Utilities.DatabaseCreator.Create(DbConnection connection)
at System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
at System.Data.Entity.MigrateDatabaseToLatestVersion2.InitializeDatabase(TContext context) at System.Data.Entity.Internal.InternalContext.<>c__DisplayClassf
1.b__e()
at System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action)
at System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()
at System.Data.Entity.Internal.LazyInternalContext.b__4(InternalContext c)
at System.Data.Entity.Internal.RetryAction1.PerformAction(TInput input) at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action
1 action)
at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase()
at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
at System.Data.Entity.Internal.Linq.InternalSet1.Initialize() at System.Data.Entity.Internal.Linq.InternalSet
1.get_InternalContext()
at System.Data.Entity.Infrastructure.DbQuery1.System.Linq.IQueryable.get_Provider() at System.Linq.Queryable.Any[TSource](IQueryable
1 source)
at GCMApiSDK.DataService.d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at GCMApiSDK.AuthenticationDialog.<LoginButton_Click_1>d__11.MoveNext()
I am unable to figure out what is going wrong with that particular machine, because the same thing works for other Windows 7 users.
Plus I also tried re-installing SQL Server CE Runtime 3.5 SP2, but no luck.
To add more info, the database is successfully created in the specified location, but I'm unable to do other operations.