SQL Server - 数据库'数据库'不存在。确保正确输入名称 [英] SQL Server - Database 'Database' does not exist. Make sure that the name is entered correctly
问题描述
我试图从我的Entity框架模型生成我的数据库表,但我得到这个错误时,我执行生成查询:
I'm trying to generate my database tables from my Entity Framework model, but I'm getting this error when I execute the generation query:
Database 'Database' does not exist. Make sure that the name is entered correctly.
我可以连接到本地服务器很好。
I'm able to connect to the local server just fine.
我的连接字符串,由我在选择Database.mdf时由VS生成:
My connection string, which was generated by VS when I selected 'Database.mdf':
metadata=res://*/Models.Models.csdl|res://*/Models.Models.ssdl|res://*/Models.Models.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"
数据库肯定存在,但我注意到,服务器上只有数据库被称为master,model,msdb和tempdb。
The database definitely exists, but I've noticed that the only databases it's picking up on the server are called master, model, msdb and tempdb.
有人可以帮忙吗?
编辑:我刚刚意识到当你单击执行SQL 允许您连接到服务器。但我的DB不在服务器上,它只是一个用户实例数据库。但这是唯一的选择,所以我如何对我的数据库执行?我已在服务器资源管理器中打开数据库。
I've just realised that the SQL connection dialog that comes up when you click "Execute SQL" allows you to connect to a server. But my DB isn't on a server, it's just a user instance database. But that's the only option, so how would I execute against my database? I have the database open in the 'Server Explorer'.
推荐答案
连接字符串指的是用户实例数据库是你想要的?
The connection string is referring to a user instance database is that what you intended? I got the impression possibly not from the question.
如果不尝试将其更改为 Data Source = ServerName\ InstanceName; Initial Catalog = Database; Integrated Security = True;
If not try changing it to Data Source=ServerName\InstanceName;Initial Catalog=Database;Integrated Security=True;
这篇关于SQL Server - 数据库'数据库'不存在。确保正确输入名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!