Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework: Modeling against an existing database scheme

I've been scratching my head over this for over a week now and haven't gotten anywhere :( We have an existing legacy DB that I'm trying to model my entities against. The tables are extremely bloated and we do not have enough bandwidth to create new, optimized tables. So I'm having to work with what we already have. However, I do not want to use all the redundant columns that are exposed by the DB. My initial plan was to use Views in my Model but that is looking to be equally hairy with very little documentation around.

Now, what would be the best way to go about creating a Model with just a select few columns? All I need is a bunch of read-only entities; so if there is a way to ignore non-nullable columns from the schema, I'd be all set. I was planning on making use of POCOs else I'd have to create my own mappings I reckon.

UPDATE: By POCOs, I mean I'd like to use the ADO.NET POCO Entity Generator.

like image 668
Praveen Avatar asked Nov 09 '10 20:11

Praveen


2 Answers

What about creating views in the DB, and only importing the views into the model?

like image 56
SteveCav Avatar answered Nov 09 '22 14:11

SteveCav


Well, if you need only a bunch of entities and if they won't change a lot during time, than I would just pick the tables you need, generate the entities with the normal wizard and all collumns, and than delete all not needed collumns manually in the model designer.

like image 24
Markus Avatar answered Nov 09 '22 13:11

Markus