Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 97371

How to add migration in the multi-project solution?

$
0
0

I'm using VSCode and I'm struggling to add my first migration in the "multi-project solution". Usually I was doing one .csproj per project, but recently I decided to play with the .sln file and I hit the wall while doing migrations. This is my project structure:

MyApi
  - src
     - MyApi.Domain
     - MyApi.Infrastructure (this is where my DbContext is)
     - MyApi.WebApi (this is where my connection sting is)
  - tests
  - MyApi.sln

I'm trying to create the database in PostgreSQL database, so this are the packages I installed in my MyApi.Infrastructure project.

<ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.2">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.3" />
    <PackageReference Include="Microsoft.NETCore.App" Version="2.2.8" />
    <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.2" />
    <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.Design" Version="1.1.1" />
  </ItemGroup>

I'm trying to run migration while in the Infrastructure project, but I'm getting this error:

Unable to create an object of type 'MyDbContext'. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728

It's not a surprise, because it doesn't even know the connection string.

How should I handle migrations in such project structure?


Viewing all articles
Browse latest Browse all 97371

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>