如何使数据库转到SSMS而不是localdb? [英] How to make the database go to SSMS instead of localdb?
问题描述
我能够在Windows身份验证和SQL Server身份验证下登录SSMS.但是我在SQL Server Management Studio的任何地方都看不到数据库.在Visual Studio中,即使我已更改连接字符串以在我的SSMS中创建数据库,它也会转到localDb.
有时,我可以在VS Server Explorer的数据连接"下看到名为"BookServiceContext"的名称,但是当我单击该连接时,会显示此错误消息
>无法打开登录请求的数据库"BookServiceContext".登录失败.
用户"MLS \ AAnwar"登录失败.
我该怎么做才能将其连接到SSMS中的正确连接?
我尝试过的事情:
我已经更改了与SSMS服务器的连接字符串,但仍在localDb中创建了数据库.我似乎无法弄清楚为什么?
I am able to log into SSMS under Windows Authentication and SQL Server Authentication. But I am not seeing the Database anywhere in the SQL Server Management Studio. In Visual Studio, it goes to the localDb even though I have changed the connection string to have the db created in my SSMS.
Sometimes, I can see the name `BookServiceContext` under Data Connections in VS Server Explorer, but when I click on the connection I get this error message
> Cannot open database "BookServiceContext" requested by the login. The login failed.
Login failed for user ''MLS\AAnwar''.
What can I do so that it goes to the right connection in my SSMS?
What I have tried:
I have changed my connection string with my SSMS server, but the database still gets created in the localDb. I cannot seem to figure out why?
<!--<add name="BookServiceContext" connectionString="Data Source=(localdb)\MSSQLLocalDB; Initial Catalog=BookServiceContext-20170328200803; Integrated Security=True; MultipleActiveResultSets=True; AttachDbFilename=|DataDirectory|BookServiceContext-20170328200803.mdf"
providerName="System.Data.SqlClient" />-->
<add name="BookServiceContext" connectionString="Data Source=AA5570LT;Initial Catalog=BookServiceContext;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
推荐答案
在过去两天努力解决此问题后,终于使它工作了.我要做的只是在解决方案资源管理器中将项目设置为启动项目",它解决了该问题.数据库是在正确的服务器中创建的,其中包含所有数据.
After working my head off with this issue for the past 2 days, finally have it working. All I had to do was set the Project as a "StartUp Project" in Solution Explorer and it fixed the issue. The database was created in the right Server with all the data.
这篇关于如何使数据库转到SSMS而不是localdb?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!