我不知道db是否创建了 [英] I dont know if the db created

查看:80
本文介绍了我不知道db是否创建了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个带有web api的第一个代码的项目



我尝试过:



这是我在包管理器控制台中得到的



PM>启用 - 迁移

检查上下文是否以现有数据库为目标...

为项目DAL启用代码优先迁移。

PM>添加迁移初始值

脚手架迁移'初始'。

此迁移文件的Designer代码包含当前Code First模型的快照。此快照用于在您构建下一次迁移时计算模型的更改。如果您对要在此迁移中包含的模型进行其他更改,则可以通过再次运行Add-Migration Initial重新构建它。

PM>更新数据库

指定'-Verbose'标志以查看应用于目标数据库的SQL语句。

应用显式迁移:[201810282115304_Initial]。

应用显式迁移:201810282115304_Initial。

运行种子方法。

PM>更新 - 数据库-Verbose

使用StartUp项目'BL'。

使用NuGet项目'DAL'。

指定'-Verbose'标志查看正在应用于目标数据库的SQL语句。

目标数据库是:'DAL.FinalContext'(DataSource:(localdb)\ mssqllocaldb,Provider:System.Data.SqlClient,Origin:Convention )。

没有待定的显式迁移。

运行种子方法。

PM>





但我看不到创建的数据库(如果它创建)

i看到我有两个文件,第一个是:Model1.Desiner.cs

第二个是:Models1.edmx.diagram

这个文件连接到创建的数据库吗?

如果是 - 我需要做什么用它?

如果没有 - 那么问题是什么?

谢谢!

i created a project with firstcode with web api

What I have tried:

this what i got in the package manager console

PM> Enable-Migrations
Checking if the context targets an existing database...
Code First Migrations enabled for project DAL.
PM> Add-Migration Initial
Scaffolding migration 'Initial'.
The Designer Code for this migration file includes a snapshot of your current Code First model. This snapshot is used to calculate the changes to your model when you scaffold the next migration. If you make additional changes to your model that you want to include in this migration, then you can re-scaffold it by running 'Add-Migration Initial' again.
PM> Update-Database
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Applying explicit migrations: [201810282115304_Initial].
Applying explicit migration: 201810282115304_Initial.
Running Seed method.
PM> Update-Database -Verbose
Using StartUp project 'BL'.
Using NuGet project 'DAL'.
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Target database is: 'DAL.FinalContext' (DataSource: (localdb)\mssqllocaldb, Provider: System.Data.SqlClient, Origin: Convention).
No pending explicit migrations.
Running Seed method.
PM>


but i cant see the db that created (if it created)
i see that i have two files, the first is : Model1.Desiner.cs
the second is: Models1.edmx.diagram
are this files connected to the db that created?
if yes - what do i need to do with it?
and if no - so whats is the problem
thanks!

推荐答案

这些是文件在您的项目中,让应用程序知道DB上下文应该是什么样子。



确定它是否已创建的最简单方法是尝试连接并使用它(数据库)
Those are files within your project that let the application know what the DB context should look like.

The easiest way to determine if it was created would be try to connect to and use it (the DB)


这篇关于我不知道db是否创建了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆