c# - 不要创建 codefirst DB .net
问题描述
我删除了我的数据库,然后DbContext
重新构建,但没有创建数据库。我尝试了迁移,但始终无法构建。然后我尝试放入-v
包管理器控制台,它返回了这个:
-v : The term '-v' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ -v
+ ~~
+ CategoryInfo : ObjectNotFound: (-v:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
数据库上下文:
public class User
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Required]
public int Id { get; set; }
[Required]
public string Nickname { get; set; }
[Required]
public string Password { get; set; }
[Required]
public string Email { get; set; }
}
public class DrawContext : DbContext
{
public DrawContext() : base("name=DrawDB_cs")
{
}
public virtual DbSet<User> Users { get; set; }
应用程序配置:
<connectionStrings>
<add name="DrawDB_cs"
connectionString="data source=(localdb)\MSSQLLocalDB;initial catalog=DrawDB;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>