ASP。NET Web API数据库没有在localdb中创建

时间:2021-03-06 10:25:30

I have created an asp.net web api 4.5.2 project and I can't find the database that it's using for adding users. The info in the connection string:

我创建了一个asp.net web api 4.5.2项目,我找不到它用来添加用户的数据库。连接字符串中的信息:

Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-WebApplicationTest2-20160906022916.mdf;Initial Catalog=aspnet-WebApplicationTest2-20160906022916;Integrated Security=True. 

But when I check the app_data directory it's empty. Where can I find this database?

但是当我检查app_data目录时,它是空的。我在哪里可以找到这个数据库?

1 个解决方案

#1


6  

Database creation for templates are delayed until a request is sent.

在发送请求之前,模板的数据库创建将被延迟。

Run your server and POST following JSON with Content-Type: application/json header to http://localhost:xxx/api/Account/Register:

运行您的服务器,以Content-Type: application/ JSON头根据JSON发布到http://localhost:xxx/api/Account/Register:

{
  "Email": "test@test.com",
  "Password": "TestTest1!",
  "ConfirmPassword": "TestTest1!"
}

You should get 200: OK.

你应该得到200。

I am using Advanced REST client.

我正在使用高级REST客户端。

ASP。NET Web API数据库没有在localdb中创建

After that database will be created in App_Data folder. If server returned 200: OK and App_Data is empty, Do the following steps:

之后将在App_Data文件夹中创建该数据库。如果服务器返回200:OK且App_Data为空,则执行以下步骤:

In Visual Studio go to View menu. Select SQL Server Object Explorer(or press Ctrl+\, Ctrl+S).

在Visual Studio中,去查看菜单。选择SQL Server对象资源管理器(或按Ctrl+\, Ctrl+S)。

Your SQL server should be there. You can find your database in Databases folder.

您的SQL服务器应该在那里。您可以在database文件夹中找到您的数据库。

ASP。NET Web API数据库没有在localdb中创建 ASP。NET Web API数据库没有在localdb中创建

If you need specifically the data file, then expand Databases folder, right click on which one you need and click on Properties. Scroll down to see Current Connection Parameters.

如果需要特定的数据文件,那么展开database文件夹,右键单击需要的文件夹,然后单击Properties。向下滚动查看当前连接参数。

ASP。NET Web API数据库没有在localdb中创建

#1


6  

Database creation for templates are delayed until a request is sent.

在发送请求之前,模板的数据库创建将被延迟。

Run your server and POST following JSON with Content-Type: application/json header to http://localhost:xxx/api/Account/Register:

运行您的服务器,以Content-Type: application/ JSON头根据JSON发布到http://localhost:xxx/api/Account/Register:

{
  "Email": "test@test.com",
  "Password": "TestTest1!",
  "ConfirmPassword": "TestTest1!"
}

You should get 200: OK.

你应该得到200。

I am using Advanced REST client.

我正在使用高级REST客户端。

ASP。NET Web API数据库没有在localdb中创建

After that database will be created in App_Data folder. If server returned 200: OK and App_Data is empty, Do the following steps:

之后将在App_Data文件夹中创建该数据库。如果服务器返回200:OK且App_Data为空,则执行以下步骤:

In Visual Studio go to View menu. Select SQL Server Object Explorer(or press Ctrl+\, Ctrl+S).

在Visual Studio中,去查看菜单。选择SQL Server对象资源管理器(或按Ctrl+\, Ctrl+S)。

Your SQL server should be there. You can find your database in Databases folder.

您的SQL服务器应该在那里。您可以在database文件夹中找到您的数据库。

ASP。NET Web API数据库没有在localdb中创建 ASP。NET Web API数据库没有在localdb中创建

If you need specifically the data file, then expand Databases folder, right click on which one you need and click on Properties. Scroll down to see Current Connection Parameters.

如果需要特定的数据文件,那么展开database文件夹,右键单击需要的文件夹,然后单击Properties。向下滚动查看当前连接参数。

ASP。NET Web API数据库没有在localdb中创建