如何解决SQL Server CE Entity Framework代码优先,指定的连接未指定初始目录或AttachDbFileName
我有一个使用代码优先方法与SQL Server CE和EF一起使用的桌面应用程序,我有大量的用户在使用它。
我要传递给 DbContext 类构造函数的连接字符串,
@"Data Source=" + Path.Combine("Path to local app data","Databasename.sdf") + ";Password=mypassword"
但是在一台Windows 7 SP1(32位)计算机上,出现以下错误:
System.InvalidOperationException:无法完成操作。提供的SqlConnection没有指定初始目录或AttachDBFileName。
在System.Data.Entity.SqlServer.SqlProviderServices.GetOrGenerateDatabaseNameAndGetFileNames(SqlConnection sqlConnection,String&databaseName,String&dataFileName,String&logFileName)
在System.Data.Entity.SqlServer.SqlProviderServices.DbCreateDatabase(DbConnection连接,可空1 commandTimeout,StoreItemCollection storeItemCollection) at System.Data.Entity.Core.Common.DbProviderServices.CreateDatabase(DbConnection connection,Nullable
1 commandTimeout,StoreItemCollection storeItemCollection)
在System.Data.Entity.Core.Objects.ObjectContext.CreateDatabase()处
在System.Data.Entity.Migrations.Utilities.DatabaseCreator.Create(DbConnection连接)处
在System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(操作mustSucceedToKeepDatabase)
在System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)处
位于System.Data.Entity.MigrateDatabaseToLatestVersion2.InitializeDatabase(TContext context) at System.Data.Entity.Internal.InternalContext.<>c__DisplayClassf
1.b__e()
在System.Data.Entity.Internal.InternalContext.PerformInitializationAction(动作)上
在System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()
在System.Data.Entity.Internal.LazyInternalContext.b__4(InternalContext c)
在System.Data.Entity.Internal.RetryAction1.PerformAction(TInput input) at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action
1操作处)
在System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase()
在System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(TypeEntityType)
位于System.Data.Entity.Internal.Linq.InternalSet1.Initialize() at System.Data.Entity.Internal.Linq.InternalSet
1.get_InternalContext()
位于System.Data.Entity.Infrastructure.DbQuery1.System.Linq.IQueryable.get_Provider() at System.Linq.Queryable.Any[TSource](IQueryable
1源)
在GCMApiSDK.DataService.d__12.MoveNext()
---从之前引发异常的位置开始的堆栈跟踪---
在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)上
在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)上
在System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(任务任务)处
在GCMApiSDK.AuthenticationDialog上。d__11.MoveNext()
我无法弄清楚那台特定的计算机出了什么问题,因为同样的事情适用于其他Windows 7用户。
另外,我还尝试重新安装SQL Server CE Runtime 3.5 SP2,但没有成功。
要添加更多信息,请在指定位置成功创建数据库,但是我无法执行其他操作。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。