Can dotnet-ef-dbcontext-scaffold ignore schemas?

entity-framework-core scaffolding

Question

We're working on a new ASP.Net Core application, and plan on using identity. Currently, we have 2 DbContext files, the ApplicationDbContext file which inherits from IdentityDbContext for the Identity functions, and our own ProjectDbContext for the rest of the tables.

We have all of the tables, both for identity and the rest of our project, in one database. We are using dbcontext-scaffold to create the POCO for our tables. However, it creates POCO files for the identity schema, which we don't need.

1
1
9/2/2016 5:16:05 PM

Popular Answer

You can use two separate contexts for each group of tables using command like below.

IDENTITY DBCONTEXT AND TABLES:

You can change identityDbContextwhat ever you want to specify....

dotnet ef dbcontext scaffold "server=YOUR_SERVER_NAME; Database=YOUR_DB_NAME rape; Integrated Security = false; Password = YOUR_PASSWORD; User Id = YOUR_USER_ID;" Microsoft.EntityFrameworkCore.SqlServer -o YOUR_OUTPUT_DIR_FOR_DBCONTEXT_AND_ASSOCIATED_TABLES -c identityDbContext--schema SCHEMA_NAME -t TABLE1 -t TABLE2

PROJECT DBCONTEXT AND TABLES:

You can change projectDbContext what ever you want to specify....

dotnet ef dbcontext scaffold "server=YOUR_SERVER_NAME; Database=YOUR_DB_NAME rape; Integrated Security = false; Password = YOUR_PASSWORD; User Id = YOUR_USER_ID;" Microsoft.EntityFrameworkCore.SqlServer -o YOUR_OUTPUT_DIR_FOR_DBCONTEXT_AND_ASSOCIATED_TABLES -c projectDbContext--schema SCHEMA_NAME -t TABLE1 -t TABLE2

3
9/3/2017 7:49:58 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow