-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Copy link
Description
File a bug
When using simplified output path adding a migration results in:
Include your code
Run the following
Set up project
dotnet new classlib -o UseArtifactsOutput -f net8.0 --no-restore
cd UseArtifactsOutput
echo "<Project><PropertyGroup><UseArtifactsOutput>true</UseArtifactsOutput></PropertyGroup></Project>" > Directory.Build.props
dotnet add package Microsoft.EntityFrameworkCore.SqlServer --version 8.0.0-preview.3.23174.2
dotnet add package Microsoft.EntityFrameworkCore.Design --version 8.0.0-preview.3.23174.2
dotnet buildNotice that obj directory doesn't exist.
Create DbContext.cs with:
using Microsoft.EntityFrameworkCore;
public class MyDbContext : Microsoft.EntityFrameworkCore.DbContext
{
public MyDbContext(DbContextOptions<MyDbContext> options) : base(options) { }
}
public class TemporaryDbContextFactory : Microsoft.EntityFrameworkCore.Design.IDesignTimeDbContextFactory<MyDbContext>
{
// remove static if EF stops working
public static MyDbContext Create()
{
var builder = new DbContextOptionsBuilder<MyDbContext>();
var connection = @"Data Source=(localdb)\mssqlserverlocaldb;Initial Catalog=UseArtifactsOutput";
builder.UseSqlServer(connection, opt => opt.CommandTimeout(500));
var vwContext = new MyDbContext(builder.Options);
return vwContext;
}
public MyDbContext CreateDbContext(string[] args) => Create();
}This won't work
dotnet ef migrations add First
but this will, though unfriendly
dotnet ef migrations add First --msbuildprojectextensionspath .artifacts/obj/UseArtifactsOutput
Include verbose output
The error when not including msbuildprojectextensionspath is:
error MSB4057: The target "GetEFProjectMetadata" does not exist in the project.
Unable to retrieve project metadata. Ensure it's an SDK-style project. If you're using a custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option.
Include provider and version information
EF Core version: 8.0.0-preview.3.23174.2
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: 8.0.0-preview.3
KennethHoff, djeikyb, Khaos66, YandyZaldivar, deinok and 20 more