找不到我的EF代码的第一个数据库 [英] Cant find my EF code first database
问题描述
我在做微软的MVC入门教程:
I am doing Microsoft's MVC getting started tutorial:
这包括一个代码第一个数据库的创建。
This includes the creation of a code first database.
这一切。工作正常,但我无法找到我的数据库
It all works fine, but I am not able to find my database.
这是我的的ConnectionString
:
<add name="MovieDBContext" connectionString="Data Source=.\SQLEXPRESS; Integrated Security=True" providerName="System.Data.SqlClient"/>
如果调试我的索引方法的连接情况如下:
If I debug my index Method the connection is as follow:
Data Source=.\SQLEXPRESS; Integrated Security=True
但是,在我的SQLEXPRESS实例没有数据库,我已经与SQL Server检查它管理工作室。
But there is no Database in my SQLEXPRESS Instance, I have checked it with SQL Server Management Studio.
我也无法找到任何东西,如果我寻找我的文件系统为 *。MDF
。
I also cant find anything if I search my filesystem for *.mdf
.
的App_Data
在我的项目是空的...
App_Data
in my Project is Empty...
但是,所有CRUD操作做工精细,必须有一些东西。
But all CRUD operations are working fine, there has to be something.
我可以看到该表的唯一方法是连接到 .\SQLEXPRESS
通过Visual Studio的服务器资源管理器。但如果是这样的物理位置?为什么不能我看表,如果我通过SQL Server Management Studio中连接到 .\SQLEXPRESS
?
The only way I can see that table is to connect to .\SQLEXPRESS
via the Visual Studio Server Explorer. But where is this physically located? Why cant I see the table if I connect to .\SQLEXPRESS
via SQL Server Management Studio?
任何想法?
推荐答案
您没有指定您的连接初始目录
字符串,所以可能你使用的是主
数据库。
You didn't specify the Initial Catalog
in your connection string so probably you are using the Master
database.
您需要指定初始目录
是这样的:
<add name="MovieDBContext"
connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=yourDBName;Integrated Security=True"
providerName="System.Data.SqlClient"/>
这篇关于找不到我的EF代码的第一个数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!