-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exclude Tables #3862
Comments
Try EF Core Power Tools, has a UI and persistence of table selection |
Thank you for the rapid reply! Unfortunately we need to be able to do this without a UI for our CI/CD pipeline. Table exclusion on DataProtectionKey(s) (a microsoft .net class appears to be the best option.) |
@MikeMcWilliams Design time activities during CI/CD sounds dangerous to me. |
Our SQL Server Database Project, which is also in the .sln, directly drives the models via scaffolding. We call it “Source First” Instead of “database first” or “code first”. The concept is that the schema (“source code” in the database project) is king. We will not use migrations and drive deployment through SQLPackage.exe. Scaffolding provides the models. Its a two or three-step process but it’s 100% scriptable. The really good news from a database perspective is that our DBAs love the approach. The Devs are new to this process and currently do manual alter scripting. If I can figure out how to get this last piece in I think everything will be tied together beautifully. |
Sweet. So you are using my dacpac scaffolding library. It is possible to use EF Core Power Tools from the command line but not supported. |
Not sure, did you create the scaffold part of Thank you for keeping the dialog going! |
I was referring to this package, that let's you scaffold directly from a .dacpac (with a few limitations) https://www.nuget.org/packages/ErikEJ.EntityFrameworkCore.SqlServer.Dacpac/ |
Hmm, without dotnet/efcore#6182, the recommend way to do this in would be, as you said, to use the If you really want to avoid that, you could override the design-time service that reads from the database. class MyDatabaseModelFactory : SqlServerDatabaseModelFactory
{
public override DatabaseModel Create(string connectionString, DatabaseModelFactoryOptions options)
=> Fixup(base.Create(connectionString, options);
public override DatabaseModel Create(DbConnection connection, DatabaseModelFactoryOptions options)
=> Fixup(base.Create(connection, options);
DatabaseModel Fixup(DatabaseModel database)
{
var dataProtectionKeys = database.Tables.First(t => t.Name == "DataProtectionKeys");
database.Tables.Remove(dataProtectionKeys);
return database;
}
} It will also be able to skip generating the classes by using a custom template once we ship dotnet/efcore#4038. |
Are table exclusions available now? |
@MikeMcWilliams Tracked by dotnet/efcore#6182 |
In a project, I am leveraging DataProtectionKey from using Microsoft.AspNetCore.DataProtection.EntityFrameworkCore and unable to exclude the DataProtectionKeys table from scaffolding. I have a partial class file that is intended not to be a part of the scaffolding. How can the DataProtectionKeys table be ignored in the scaffolding? (It's not optimal to maintain a table (--table option) to list the tables for scaffolding) Please advise.
MyContextPartial.cs
MyContext.cs
This file is scaffolded by ef-core and contains all the tables including
DataProtectionKeys
which should be skipped/ignored.Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: