loresoft / EntityFrameworkCore.Generator

Generate Entity Framework Core model from an existing database

Home Page:https://efg.loresoft.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Able to exclude tables from generation

HerrLiljegren opened this issue · comments

I'm having a large database that contains some tables that create issues with EF Core, I would like to be able to exclude them using the config.

What I do now is listing all the tables under database.tables and commenting away the tables I want to skip.

It's a very useful feature by @HerrLiljegren. Any master contributors (@dattaproffs @pwelter34 @tjackadams @hamedsabzian ) should merge this. Pending from a long time.

Thanks

agree, however, the issue with this implementation, as i understand it, is that you have to list all the tables in the include sections. if you're going though all that effort, just don't include the ones you don't want. Ideally, it would be better if you could only put the ones to skip. I'll see if i can come up with something.

@pwelter34 Thank you for the reply.

Yes, your view is absolutely correct but think in terms of a project/framework that have more than 50 existing tables at fresh start and they all are collected at compile time using some base interface. In that case, I have to list down all existing 50 tables into include section, whereas my custom tables are only a few (say maximum 10-15). In such a case anyone can use the exclude section. Also this will save my effort for writing down into include section when there is a requirement of creating a new table arise. It's up to the developer how they want to use it.

If it slows down the generation process then we need to think. But I don't think this is the case here.

Thanks

This is implement in v3 now.

To exclude a table, simply specify in the database -> exclude section in the configuration file.

example.

database:
  provider: SqlServer
  connectionString: Data Source=(local);Initial Catalog=TrackerSchema;Integrated Security=True
  exclude:
    - exact: 'dbo.SchemaVersions'
    - regex: 'dbo\.SchemaVersions$'

The expression can now be exact or regex. When exact, will be direct string match. When regex, will use regular expression to match.