0

we have a existing MS SQL Database where the foreign Keys are not mapped properly. Furthermore some Views without PKs.

My Question now is should I generate the POCOs on my self with e.g. Reverse Engineer Code first or should I use the EDMX-Designer?

I tried both. With the Reverse Engineer Code first I got all the POCOs which I need but additionally crap Views and Tables which I don't want to map. The Database-first concept provided me the ability to select my Tables and Views. But at the end I got a mapping where Views had several Keys which are not design in the database. It seems like this concept just works with a proper designed DB.

So what is your advise?

Thanks a lot!

Regards, Oliver

McKay
  • 12,334
  • 7
  • 53
  • 76
Rayk
  • 63
  • 8
  • 1
    I think this will come down to your personal preference, and just trial and error until you get what you are looking for. Personally, I prefer to design the database, and generate the model from the database. So, in this particular situation, I would prefer to fix the database directly, and then generate an EF model from that. Trying to generate the model with improperly mapped Foreign Keys in the database seems like a nightmare to me. – Joe Brunscheon Aug 14 '13 at 15:56
  • possible duplicate of [Code-first vs Model/Database-first](http://stackoverflow.com/questions/5446316/code-first-vs-model-database-first) – magnattic Jan 08 '14 at 14:33

1 Answers1

0

I agree w/ Joe, it is ultimately going to be a preference + tech decision. This may help you out from an EF expert...

Demystifying Entity Framework Strategies: Model Creation Workflow

Also, if reverse engineering the database adds unwanted tables/views is it not possible to just delete the generated classes?

bbqchickenrobot
  • 3,592
  • 3
  • 45
  • 67