user366312
user366312

Reputation: 16938

Entity Framework - Autogeneration vs Manually Creation of Entities

You can refer to this post of mine.

It is not the case that, someone will be able to generate perfect Entities from the database tables every time.

If any entity is not looking perfect, how can I tweak it? And how should I tweak it?

Or should I search for the flaw of relations in the Database, fix it first and then try to generate Entities over and over again until the desired entity is generated?

But it may happen that, I would become unable to figure out the reason of an imperfect entity being generated only looking at the database tables.

Upvotes: 1

Views: 303

Answers (2)

Shiraz Bhaiji
Shiraz Bhaiji

Reputation: 65411

We generate the EF model based on the database. When the database changes we refresh the model. This works fine for us.

It is only if you are doing something special that you need to tweek your entities.

Upvotes: 1

twk
twk

Reputation: 3120

You should clarify your requirements: should be everything created automatically from database or you allow hand-made updates or will do it manually (once automatically then only manual updates).

Remember, that from time to time after db structure changes you will have to generate entities again, then you may lost your changes. Consider using partial classes, so some of your code changes could be persistent across automatic generations.

But in your case let's try to figure out how how the MS has prepared the demo database and try to follow the rules. Maybe you would like to read some database design guides?

More details about your environment could help with more precise answer.

Upvotes: 2

Related Questions