Entity Framework 7 RC1 Reverse Engineer Entire DB only?

entity-framework-core

Question

I have successfully reverse engineered my DB in EF7 RC1, specifically using the Package Manager Console command 'Scaffold-DbContext', as described in their documentation.

First, are there any options for reverse engineering just some of the tables in the DB? Most of my projects use only a few of the hundreds of tables in the DB.

Secondly, if we change the DB and want to reverse engineer it a second time what is the correct procedure? If I simply re-run the command it says 'Build failed' presumably because the models already exist.

Popular Answer

are there any options for reverse engineering just some of the tables in the DB?

Yes. To see options, execute get-help Scaffold-DbContext in the Package Manager Console. This is the output for 7.0.0-rc1-final. To limit selection to only some tables, use the -Tables options

PM> get-help Scaffold-DbContext

NAME
    Scaffold-DbContext

SYNOPSIS
    Scaffolds a DbContext and entity type classes for a specified database.


SYNTAX
    Scaffold-DbContext [-Connection] <String> [-Provider] <String> [-OutputDirectory <String>] [-ContextClassName <String>] [-Schemas <String[]>] [-Tables <String[]>] [-DataAnnotations] 
    [-Project <String>] [-StartupProject <String>] [-Environment <String>] [<CommonParameters>]


DESCRIPTION
    Scaffolds a DbContext and entity type classes for a specified database.


RELATED LINKS
    about_EntityFramework 

REMARKS
    To see the examples, type: "get-help Scaffold-DbContext -examples".
    For more information, type: "get-help Scaffold-DbContext -detailed".
    For technical information, type: "get-help Scaffold-DbContext -full".
    For online help, type: "get-help Scaffold-DbContext -online"

if we change the DB and want to reverse engineer it a second time what is the correct procedure?

Delete your old model classes and context and re-run reverse engineering from the updated database. Scaffold-DbContext does not make in-place updates in RC1.



Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why