我的代码就像这样
public class Address
{
public int Id { get; set; }
public string City { get; set; }
public int PostNo { get; set; }
public string Street { get; set; }
}
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("DefaultConnection", throwIfV1Schema: false)
{
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
public System.Data.Entity.DbSet<MearnIt.Models.Address> Addresses { get; set; }
}
当我在nuget包管理器控制台上运行Update-Database命令时,它会出现此错误。
Cannot find the object "dbo.Addresses" because it does not exist or you do not have permissions.
我不知道为什么它会抛出这样的错误。任何人都可以指出她的错误吗?
答案 0 :(得分:1)
尝试使用命令行:
打开文件浏览器并浏览到项目的文件夹(在 src 文件夹中)。按住键盘上的 shift ,同时右键单击File explorer并选择“在此打开命令窗口”
应出现命令窗口。现在,输入以下命令:
dotnet ef migrations add Initial.
等待命令执行完毕。接着输入:
donet ef database update
请记住,为了更改数据库,您需要删除Data / Migrations文件夹中的Initial.cs文件,然后再运行命令。现在再次运行命令。
希望有所帮助。