Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# .NET CORE 5-如果我在不同的项目中进行迁移并使用IDesignTimeDbContextFactory,则创建迁移失败_C#_Entity Framework Core - Fatal编程技术网

C# .NET CORE 5-如果我在不同的项目中进行迁移并使用IDesignTimeDbContextFactory,则创建迁移失败

C# .NET CORE 5-如果我在不同的项目中进行迁移并使用IDesignTimeDbContextFactory,则创建迁移失败,c#,entity-framework-core,C#,Entity Framework Core,我得到以下错误: PS Microsoft.PowerShell.Core\FileSystem::\QNAPBOX\Web\1.0-AURELIA\1.0-DOTNET Core 5 ODATA\JobsLedger.CATALOG>DOTNET ef迁移添加初始--上下文CATALOGContext-s../JobsLedger.API MSBUILD:错误MSB1009:项目文件不存在。 开关:\\QNAPBOX\Web\1.0-AURELIA\1.0-dotnetcore 5-ODATA

我得到以下错误:

PS Microsoft.PowerShell.Core\FileSystem::\QNAPBOX\Web\1.0-AURELIA\1.0-DOTNET Core 5 ODATA\JobsLedger.CATALOG>DOTNET ef迁移添加初始--上下文CATALOGContext-s../JobsLedger.API MSBUILD:错误MSB1009:项目文件不存在。 开关:\\QNAPBOX\Web\1.0-AURELIA\1.0-dotnetcore 5-ODATA\JobsLedger.CATALOG\JobsLedger.CATALOG.csproj 无法检索项目元数据。确保它是基于MSBuild的.NET核心项目。如果使用的是自定义BaseMediateOutputPath或MSBuildProjectExtensionsPath值,请使用--MSBuildProjectExtensionsPath选项

它找不到我认为在那里的项目文件

error MSB1009: Project file does not exist.
以下是我如何设置项目的:

我有一个web项目(JobsLedger.API)和许多类库,其中一个是“JobsLedger.CATALOG”,我希望迁移放在哪里

在web项目中,我有以下内容:

public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<CATALOGContext> {
        public CATALOGContext CreateDbContext(string[] args) {
            var configuration = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("appsettings.json")
                .Build();

            var builder = new DbContextOptionsBuilder<CATALOGContext>();

            var userSession = new UserSession {
                ConnectionString = configuration.GetConnectionString("CatalogConnection")
            };

            builder.UseSqlServer(userSession.ConnectionString);

            return new CATALOGContext(builder.Options, userSession);
        }
    }
        services.AddDbContext<CATALOGContext>(options => options.UseLazyLoadingProxies().UseSqlServer(_configuration.GetConnectionString("CatalogConnection"), b => b.MigrationsAssembly("JobsLedger.CATALOG")));
"ConnectionStrings": {
    "CatalogConnection": "Server=(localdb)\\mssqllocaldb;Database=catalogDb;Trusted_Connection=True;MultipleActiveResultSets=true"
},
dotnet ef migrations add INITIAL --context CATALOGContext -s ../Jobsledger.API
要运行迁移,我在项目库JobsLedger.CATALOG中打开powershell

然后,我运行以下命令:

public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<CATALOGContext> {
        public CATALOGContext CreateDbContext(string[] args) {
            var configuration = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("appsettings.json")
                .Build();

            var builder = new DbContextOptionsBuilder<CATALOGContext>();

            var userSession = new UserSession {
                ConnectionString = configuration.GetConnectionString("CatalogConnection")
            };

            builder.UseSqlServer(userSession.ConnectionString);

            return new CATALOGContext(builder.Options, userSession);
        }
    }
        services.AddDbContext<CATALOGContext>(options => options.UseLazyLoadingProxies().UseSqlServer(_configuration.GetConnectionString("CatalogConnection"), b => b.MigrationsAssembly("JobsLedger.CATALOG")));
"ConnectionStrings": {
    "CatalogConnection": "Server=(localdb)\\mssqllocaldb;Database=catalogDb;Trusted_Connection=True;MultipleActiveResultSets=true"
},
dotnet ef migrations add INITIAL --context CATALOGContext -s ../Jobsledger.API
其中JobsLedger.API是web项目,上面提到的migrations.cs文件是

然后我得到上面的错误消息

它过去有用,现在不行了。有没有人能告诉我我做错了什么,或者我需要做些什么来更新它,让它工作