Ajay Suwalka
Ajay Suwalka

Reputation: 531

How to keep domain model separate from repository and enable migrations

I've a scenario where the project structure as following

  1. DomainModels
  2. Repository --ReferenceTo 'DomainModels'
  3. Curator --ReferenceTo 'Repository'
  4. MVC project -ReferenceTo 'Curator'

Now the problem is If I keep My DbContext in DomainModel which I'm supposed to keep, I cann't enable Db Migrations.

-- The only solution I've come across is to give the reference of 'DomainModels' to 'MVC projects' using Enable-Migration MigrationName SomeAdditionalParameter here

Upvotes: 0

Views: 65

Answers (1)

John Mc
John Mc

Reputation: 2933

Why is this a problem? I have a Data project which contains the models and DbContext. My web and business projects reference this. When I run the Add-Migration step, I just select the Data project in the project dropdown and it uses the connection string in the web.config in the web project. It works well and I have no problems.

Upvotes: 1

Related Questions