在运行时加载和保存 .sdf
我正在构建一个 C# 应用程序,该应用程序使用 SQL Server Compact 4.0 数据库 (.sdf) 和实体框架来存储数据。我希望能够从此应用程序中加载/保存文件,以便用户可以加载不同的数据库或将数据库备份到 USB,例如。
我知道你可以在代码中创建一个 sdf,但是我如何在运行时加载它(连接字符串)?
我的问题是,这一定是一件常见的事情,最好的方法是什么?有没有任何指南可以做到这一点?
或者你推荐另一种方法来解决我的问题吗?
//目标编码器
I'm building an C#-application that uses an SQL Server Compact 4.0 database (.sdf) with Entity Framework for data. I want to be able to load/save-files from within this application so that the user can load a different database or backup the database to an USB eg.
I know you can create an sdf in code, but how can i load it at runtime (The connectionstring)?
My question is that this must be a common thing to do, what is the best way to go about it? is there any guides out there to do this?
or do you reccomend another way to go about my problem?
//ObjectiveCoder
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该使用
SqlCeConnectionStringBuilder
创建包含文件路径的连接字符串。You should use a
SqlCeConnectionStringBuilder
to create a connection string containing your file path.