简体   繁体   English

将SQLite数据库保存到特定文件

[英]Saving SQLite Database to specific File

Introduction 介绍

I am using the official sqlite NuGet package (3.13.0) and entity framework (6.2.0). 我正在使用官方的sqlite NuGet软件包 (3.13.0)和实体框架 (6.2.0)。 My initial connection string is data source=sample-database.sqlite . 我的初始连接字符串data source=sample-database.sqlite

My Question 我的问题

How can I save the complete database to a different file (eg D:\\Path\\To\\NewFile.sqlite )? 如何将完整的数据库保存到其他文件(例如D:\\Path\\To\\NewFile.sqlite )? I just can think of copying the database file to the new location and renaming it, but this solution feels kind of weird. 我只是可以考虑将数据库文件复制到新位置并重命名,但是这种解决方案感觉有点奇怪。

Thank you. 谢谢。 Any help is appreciated! 任何帮助表示赞赏!

How can I save the complete database to a different file (eg D:\\Path\\To\\NewFile.sqlite)? 如何将整个数据库保存到其他文件(例如D:\\ Path \\ To \\ NewFile.sqlite)? I just can think of copying the database file to the new location and renaming it, but this solution feels kind of weird. 我只是可以考虑将数据库文件复制到新位置并重命名, 但是这种解决方案感觉有点奇怪。

Nope. 不。 Not weird. 不奇怪 I have done this and it works just fine. 我已经做到了,并且效果很好。 Just need to remember that you may need to be aware of the new DB location when you add another migration + update-database, (if the connection string is defined in various places) 只需记住,添加另一个迁移+更新数据库时(如果连接字符串在各个位置定义),您可能需要知道新的数据库位置。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM