Kornél Regius
Kornél Regius

Reputation: 3049

How to specify output directory for Entity Framework Model-First entity generation?

We are using Entity Framework 6 with Model-First, which by default results that our entities, the dbcontext, the .tt files, and the model files are crammed in a single folder, without any structure.

I would like to achieve some separation, at least something like this:

Project root/Entities/entities generated from model
Project root/Repository/everything else (.tt, .edmx, etc...)

Is this possible?

Upvotes: 3

Views: 2604

Answers (3)

Ehsan
Ehsan

Reputation: 834

sure you can! I don't know what do you mean by

Project root/Entities/entities generated from model
Project root/Repository/everything else (.tt, .edmx, etc...)

but you can even separate the assembly. you can have you domain entities, repository and Context class in an assembly or in a namespace.(it's better to do that for make you app maintainable). take a look at this and this blog posts. hope it helps

Upvotes: 0

Jammer
Jammer

Reputation: 10208

What you could do in order to get a bit closer to what you want is to use EntityFramework Power Tools to reverse engineer the database and produce a set of POCO classes that can be used as your data access.

It's often described as Code-Second I believe.

You can installed the Power Tools and then select the location in your solution where you want the classes to be and then right-click and select "Reverse Engineer Database" {sic}

Upvotes: 1

simon at rcl
simon at rcl

Reputation: 7344

It is not. EF is in charge of where it puts stuff and where it expects them to be; you can't change that.

Upvotes: 1

Related Questions