簡體   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

因此,在Visual Studio 2017的程序包管理器控制台中添加新遷移並執行Update-database命令后,出現以下錯誤:

找不到內容根文件夾!

問題似乎是實體框架dbcontext某種程度上沒有連接到任何數據庫。

如果我運行Get-Dbcontext命令,我將得到相同的錯誤。 這在哪里或如何鏈接?

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM