简体   繁体   English

您如何移动Ado.net实体数据库?

[英]How can you move the Ado.net entity database?

At the moment my application has a database in the installation directory, but I would like to move it to the users local app data folder. 目前,我的应用程序在安装目录中有一个数据库,但是我想将其移动到用户本地应用程序数据文件夹中。 How can I do this? 我怎样才能做到这一点? CAN you do this? 你能做这个吗?

Well, you could do this: 好吧,你可以这样做:

File.Move(pathToDatabase,
    Path.Combine(Environment.GetFolderPath(SpecialFolder.LocalApplicationData),
        "databaseName.mdf"));

but you need to remember to change the connection string for the application as well (wherever you're storing that). 但您需要记住也要更改应用程序的连接字符串(无论您将其存储在何处)。

it would be better you mentioned which database technology you use but odds are high you can simply use File.Move. 最好提到使用哪种数据库技术,但是您可以简单地使用File.Move的可能性就很高。 of course dont forget to arrange connection string for new location. 当然不要忘记为新位置安排连接字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何以编程方式从ADO.Net实体模型创建数据库? - How to programatically create a database from an ADO.Net Entity Model? 如何保护ado.net实体在本地计算机上生成的数据库 - How to protect ado.net entity generated database on a local machine ADO.net 如何将数据库单元格变成 integer? - ADO.net How do you make a database cell into an integer? 如何将传统的ADO.Net搜索转换为Linq实体 - How can Convert traditional ADO.Net search to Linq Entity 我怎么知道数据库中是否存在这样的值? (ADO.NET) - How can I know if such value exists in database? (ADO.NET) 如何改善这个数据库连接类? (ADO.NET) - How can this database connection class be improved? (ADO.NET) 如何使用 ADO.NET 创建数据库触发器 - How to create a database trigger with ADO.NET 带有数据库和ADO.NET实体框架的.NET TDD - 集成测试 - .NET TDD with a Database and ADO.NET Entity Framework - Integration Tests 无法使用“ADO.NET 实体数据模型”创建数据库 Model:缺少程序集? - Can't create Database Model using 'ADO.NET Entity Data Model': missing assemblies? 如何在Ado.net实体框架中使用SaveChanges()方法? - How do you use SaveChanges() method in Ado.net Entity Framework?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM