简体   繁体   English

项目内部的MDF数据库。 Visual Studio Server资源管理器不显示对数据的更改

[英]MDF database inside project. Visual Studio Server Explorer not showing changes to the data

I've added a new MDF file to a .NET4.0 class library project, created a single table and a LINQ to SQL data model in order to access it. 我已经向.NET4.0类库项目中添加了一个新的MDF文件,创建了一个表和一个LINQ to SQL数据模型以便对其进行访问。 The connection string that was automatically added is: 自动添加的连接字符串为:

Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\ClosedIncidents.mdf;Integrated Security=True;User Instance=True 数据源=。\\ SQLEXPRESS; AttachDbFilename = | DataDirectory | \\ ClosedIncidents.mdf;集成安全性= True;用户实例= True

I run some code against it that first prints out the tables records to the console, add's a record, and then prints out all records again. 我针对它运行一些代码,该代码首先将表记录打印到控制台,添加一条记录,然后再次打印出所有记录。 The idea is to just check that after VS closes the MDF file retains the changes. 想法是仅检查VS关闭后MDF文件是否保留更改。 This is proved true as on a second run of the app it moans that it can't add the same hard coded record because it already exists. 事实证明,这是正确的,因为在第二次运行该应用程序时,它抱怨它无法添加相同的硬编码记录,因为该记录已经存在。 The issue I am pondering on, is why when in Server Explorer if I view the data of the table that it shows nothing is there. 我正在思考的问题是,为什么在服务器浏览器中查看表中的数据时,显示什么都没有。

My understanding is that it attaches the server or user sql server instance directly to the mdf file within my project. 我的理解是,它将服务器或用户sql服务器实例直接附加到项目中的mdf文件中。 Changes through the instance are written back to the source mdf, not a copy of it. 通过实例所做的更改将写回到源mdf,而不是其副本。 Why then does the program show the record being added but not Server Explorer? 为什么程序随后显示正在添加的记录,而不显示服务器资源管理器?

Chances are the file is being copied to the output directory, and so the IDE and the application are actually touching different files. 可能会将文件复制到输出目录,因此IDE和应用程序实际上正在接触其他文件。 You can confirm this by doing a clean build. 您可以通过全新构建来确认。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 这是将数据库(.mdf文件)连接到Visual Studio项目的正确方法吗? - Is this the correct way for connecting database (.mdf file) to visual studio project? 停止Visual Studio将数据库MDF复制到bin - Stop Visual Studio Copying Database MDF to bin Visual Studio 2008:添加的项目未显示在解决方案资源管理器中 - Visual Studio 2008: Added Project not showing up in Solution Explorer Visual Studio 2015数据库(.mdf)版本控制 - Visual Studio 2015 database(.mdf) versioning 如何在Visual Studio中添加SQL Server数据库文件(.mdf)而不安装SQL Server Express Edition? - How to add SQL Server database file (.mdf) in Visual Studio without installing SQL Server Express Edition? 如何让 Visual Studio 使用我的数据库,而不是位于 ASP.NET MVC 项目的 App_Data 文件夹中的 .mdf 文件? - How can I make Visual Studio use my database instead of the .mdf file located in App_Data folder in ASP.NET MVC project? Visual Studio Server Explorer是否支持自定义数据库提供程序? - Does Visual Studio Server Explorer support custom database providers? Visual Studio Server资源管理器连接到数据库,但是在代码中引发了异常 - Visual Studio Server Explorer connects to database but in code an exception is thrown Visual Studio 2013 Server Explorer自定义数据提供程序:MongoDB - Visual Studio 2013 Server Explorer custom data provider: MongoDB C#Visual Studio本地数据库路径异常(.mdf) - C# Visual Studio local database path exception (.mdf)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM