Entity Framework: Modeling an Existing Database Schema

I’ve been staring at this topic for more than a week and haven’t received anywhere :( We have an existing obsolete database that I am trying to match with my objects. The tables are extremely bloated and we do not have enough bandwidth to create new optimized tables, so I need to work with what we already have. However, I don’t want to use all the redundant columns that are displayed in the database. My initial plan was to use Views in my model, but it looks equally hairy, with very few om documentation around.

Now, what would be the best way to create a model with just a few columns? All I need is a bunch of read-only objects; so if there is a way to ignore non-null columns from the schema, I would install everything. I planned to use POCOs, otherwise I would have to create my own mappings, which I consider.

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

+6
entity-framework
source share
3 answers

How about creating views in the database and only importing the views into the model?

+2
source share

Well, if you only need a bunch of entities, and if they do not change much over time, I just select the tables you need, generate the entities with the usual wizard and all the columns, and do not delete all the columns that are not needed manually in the model designer.

+1
source share

add the table to your EF and just remove the properties you don't want. it simply will not display these DB fields.

0
source share

All Articles