简体   繁体   中英

How to add .mdf file in Visual Studio 2019?

在开发 Blazor 服务器应用程序时,我无法在 Visual Studio 2019 的新项目中找到.mdf文件类型。

For whatever it's worth... this is what I did to add an mdf database file to my Visual Studio 2019 solution:

First I had to install this nuget package: Microsoft.SqlServer.Compact

在此处输入图片说明

Then I added the mdf file to the solution like this: 在此处输入图片说明

To view and update the mdf database - open the Server Explorer

在此处输入图片说明

You can use the following steps:

  1. Go to Tools -> Options
  2. Select Database Tools -> Data Connections and provide the Sql Server Instance Name with the instance name of your database.
  3. Then go to Services by pressing Win + R and Services.msc
  4. Select the SQL Server (the instance name), right click and select Properties
  5. Then in the properties window of the service go to Log On tab and select Local System account

To add .mdf files you should have selected .NET desktop development and Data storage and processing while installation of visual studio 2019.

if you have not selected then you need to launch Visual Studio launcher and choose to modify and select it.

After updation you should see .mdf file option while adding a new item in any project.

Note: this option you will see if you add a .Net Framework project but .netcore. But once you add the file , it can be moved to any type of project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM