将现有数据库附加到sql localdb的最佳方法是什么?

编程入门 行业动态 更新时间:2024-10-25 08:24:35
本文介绍了将现有数据库附加到sql localdb的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

上下文

我正在开发一个桌面应用程序,该应用程序必须能够在与远程sql服务器的连接断开的情况下运行:SQL Server Express (我知道...)2012.我我在Visual Studio Express 2013上工作.因此,我发现最好的选择是将SQLLocalDB用作客户端本地数据库,因为我只需要导入无数据的mdf文件并处理数据同步(代表我自己一个非常简单的规则集).要将mdf文件附加到SQLLocalDB,我有两个选择,但我不清楚每个选择的后果.

I'm working on a desktop app which must be able to run in case of connection loss with the distant sql server : a SQL Server Express (I know...) 2012. I'm working on Visual Studio Express 2013. So I figured out that my best option is to use SQLLocalDB as my client local DB as I just have to import my data-free mdf file and handle the data synch (which represent a quite simple enough ruleset) by myself. To attach the mdf file to SQLLocalDB, I have two options but I do not understand clearly the consequences of each one.

解决方案1-Transact SQL

解决方案2-连接字符串

"Server=(localdb)\\v11.0;Integrated Security=true;AttachDbFileName= myDbFile.mdf;"

知道我使用Entity Framework访问代码中的数据的最佳途径是什么?

What is the best way to go knowing that I use Entity Framework to access the data in code ?

推荐答案

我认为解决方案2更好,因为它基于与databse的连接字符串.

My opinion is solution #2 is better because it's based on connection string to databse.

在SQL Express中,您也可以在T-SQL中指定一个数据库名称(USE DB_NAME).但是人们通常在连接字符串而不是T-SQL中指定db

In SQL Express you can specify a db name in T-SQL too (USE DB_NAME). But people usually specify db in a connection string rather than T-SQL

更多推荐

将现有数据库附加到sql localdb的最佳方法是什么?

本文发布于:2023-11-10 01:08:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573947.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库   方法   sql   localdb

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!