Efcore: Scaffold-DbContext with -ContextDir flag doesn't add namespace for models

Created on 14 Sep 2019  路  1Comment  路  Source: dotnet/efcore

The database context generated by Scaffold-DbContext doesn't include any using directives pointing to the models that are generated when the DbContext is placed in a different folder using the -ContextDir flag.

Steps to reproduce

  1. Reverse engineer a database using the following command-line options:

    ```
    Scaffold-DbContext "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=ContosoPets;Integrated Security=True;ConnectRetryCount=0" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -ContextDir Data -Context ContosoPetsContext
    ````

  2. Attempt to build.

  3. Note that the build fails because the the entity model classes can't be resolved in ContotoPetsContext.db.

Further technical details

EF Core version: 3.0 preview 9
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: NET Core 3.0
Operating system: Windows 1903
IDE: Visual Studio 2019 16.3.3

I'm MSFT-internal. Hit me up on Teams if you need repro help.

cc: @divega

closed-fixed customer-reported good first issue type-bug

>All comments

This is implemented in the daily build of EF Core Power Tools @camsoper

Was this page helpful?
0 / 5 - 0 ratings