简体   繁体   English

在Visual Studio中的程序包管理器控制台上执行“更新数据库”时,出现错误:找不到内容根文件夹

[英]When doing an “update-database” on the package manager console in visual studio i get error : Could not find content root folder

So after adding a new migration in the package manager console in visual studio 2017 and doing the Update-database command, I get the following error: 因此,在Visual Studio 2017的程序包管理器控制台中添加新迁移并执行Update-database命令后,出现以下错误:

Could not find content root folder! 找不到内容根文件夹!

The issue seems to be that somehow the entity framework dbcontext is not connected to any DB. 问题似乎是实体框架dbcontext某种程度上没有连接到任何数据库。

If I run the Get-Dbcontext command I get the same error. 如果我运行Get-Dbcontext命令,我将得到相同的错误。 Where or how is this linked? 这在哪里或如何链接?

public class ......DbContext : AbpZeroDbContext<Tenant, Role, User, ..........DbContext>, IAbpPersistedGrantDbContext
{
    /* Define an IDbSet for each entity of the application */

    public virtual DbSet<BinaryObject> BinaryObjects { get; set; }

    public virtual DbSet<Friendship> Friendships { get; set; }

    public virtual DbSet<ChatMessage> ChatMessages { get; set; }

    public virtual DbSet<SubscribableEdition> SubscribableEditions { get; set; }

    public virtual DbSet<SubscriptionPayment> SubscriptionPayments { get; set; }

    public virtual DbSet<Invoice> Invoices { get; set; }

    public virtual DbSet<PersistedGrantEntity> PersistedGrants { get; set; }

    public virtual DbSet<Person> Persons { get; set; }
    public virtual DbSet<Position> Positions { get; set; }

    public FutureAthletesDbContext(DbContextOptions<FutureAthletesDbContext> options)
        : base(options)
    {

    }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);

        modelBuilder.Entity<BinaryObject>(b =>
        {
            b.HasIndex(e => new { e.TenantId });
        });

        modelBuilder.Entity<ChatMessage>(b =>
        {
            b.HasIndex(e => new { e.TenantId, e.UserId, e.ReadState });
            b.HasIndex(e => new { e.TenantId, e.TargetUserId, e.ReadState });
            b.HasIndex(e => new { e.TargetTenantId, e.TargetUserId, e.ReadState });
            b.HasIndex(e => new { e.TargetTenantId, e.UserId, e.ReadState });
        });

        modelBuilder.Entity<Friendship>(b =>
        {
            b.HasIndex(e => new { e.TenantId, e.UserId });
            b.HasIndex(e => new { e.TenantId, e.FriendUserId });
            b.HasIndex(e => new { e.FriendTenantId, e.UserId });
            b.HasIndex(e => new { e.FriendTenantId, e.FriendUserId });
        });

        modelBuilder.Entity<Tenant>(b =>
        {
            b.HasIndex(e => new { e.SubscriptionEndDateUtc });
            b.HasIndex(e => new { e.CreationTime });
        });

        modelBuilder.Entity<SubscriptionPayment>(b =>
        {
            b.HasIndex(e => new { e.Status, e.CreationTime });
            b.HasIndex(e => new { e.PaymentId, e.Gateway });
        });

        modelBuilder.ConfigurePersistedGrantEntity();
    }
}

} }

这是特定于ASP零角度的问题,我们在文件夹结构中修复了该路径后,此问题已解决。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从Visual Studio中的包管理器控制台调用针对SQL Azure的update-database? - How to call update-database from package manager console in Visual Studio against SQL Azure? 使用包管理器控制台“ Update-Database”等在实体框架中以编程方式连接字符串 - Programmatically connection string in entity framework with package manager console “Update-Database” etc 当我在 package 管理器控制台中的 Visual Studio 2013 中安装实体框架时 - When I am installing Entity Framework in Visual Studio 2013 in the package manager console 为什么我在运行更新数据库时得到 Object 引用未设置为 object 的实例 - Why do I get Object reference not set to an instance of an object when running Update-Database 使用更新数据库命令MVC 4时出错 - Error when using Update-Database command MVC 4 在扩展中以编程方式访问visual studio的powershell控制台(包管理器控制台) - Access the powershell console (package manager console) of visual studio programmatically in an extension 运行更新数据库 EFCore 时出现算术溢出错误 - Arithmetic Overflow Error When running Update-Database EFCore 从visual studio命令提示符运行nuget包管理器控制台 - Run nuget package manager console from visual studio command prompt Package Manager Console Visual Studio 2019 返回新行 - Package Manager Console Visual Studio 2019 Returns New Line 在 Visual Studio 中使用 DTE 的包管理器控制台自动化 - Package Manager Console Automation using DTE in Visual Studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM