Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reverse engineering a subset of tables for Entity Framework

I'm using EF, and I've got the Entity Framework Power Tools extension, which lets me reverse engineer classes based on tables in a given database.

We have a rather extensive DB, with a lot of tables that I do not need to represent. Is there any simple way to select a subset of these, and reverse engineer only those?

like image 493
Kjartan Avatar asked Oct 03 '13 12:10

Kjartan


1 Answers

If your database is SQL Server, or SQL Server CE 4.0 then you can use the "Entity Framework Reverse POCO Generator" available at visualstudiogallery.msdn.microsoft.com

It does table filtering through the use of TableFilterExclude, TableFilterInclude.

The way the filters work are as follows:

  1. Read the schema
  2. Remove any tables that match the exclude filter, if present.
  3. Include any tables that match the include filter, if present.

Example:

TableFilterExclude = new Regex("billing|report");
TableFilterInclude = new Regex("company");

Given the following tables:

  • some_table
  • company
  • company_billing_annual
  • company_billing_ledger
  • company_reports
  • company_events
  • another_table.

Any table with billing or report in the name are immediately excluded. Any table with company in the name are included.

You are left with:

  • company
  • company_events
like image 64
Simon Hughes Avatar answered Oct 03 '22 02:10

Simon Hughes