Search code examples
.net-coreentity-framework-corevisual-studio-2017onion-architecture

ef core add-migration separate assembly for data and domainmodel


I have three projects in (VS2017 and ef core) and want to run Add-migration.

  • Web - Startup
  • Core - DomainModel - here are the entitys
  • Data - Context and migrations here. And dependes on ef core

The domainmodel have the entities and I want to have the migrationfiles/ output folder in a data project together with my context file.

I want to avoid having dependecies between domainmodel and entity framework. EntityFrameworkscore only have dependecies to Data. Any suggestions how to run add-migration with this setup to get the migrationfiles in data instead of core/domainmodel?

Add-Migration -Name InitMigration -OutputDir Migrations -Context myDBContext -Project Business\Core


Solution

  • According to @joakimja the solution was to run:

    Add-Migration command without the -Context myDBContext -Project Business\Core arguments.