-
-
Notifications
You must be signed in to change notification settings - Fork 304
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
Enhancment Request Allow for changing Access Modifiers on configuration Classes #2544
Comments
Keep in mind that this is a preview feature, potentially to be replaced by a t4 template when EF Core 6 goes out of support |
Interesting. When I looked, it didn't seem like the EF Core templates would generate a T4 template for the EntityTypeConfiguration. So I wasn't sure if efcore itself was going to continue to support T4 for that piece. (reference to the place they generate the templates: https://github.com/dotnet/efcore/blob/bb583a91d7269510ecb09a4466fee61bc62280d1/src/EFCore.Templates/EFCore.Templates.csproj#L26) |
Someone else created something see #1499 |
Given that Net 6 isn't being removed from this repo until March 2025 per #2476. That means that supporting the T4 approach won't happen before then correct? So we have at least 6 months before we'd have a way to handle this. Or if I were to turn off the DB splitting and pulled in the T4 template, would it "just work"? |
@jwyza-pi If have not tried the "would just work" scenario, but I doubt it. Alernativly you can always do som script based post processing... |
So, to the question of "just work", answer is no. The reason is that the Even if I manually change that during runtime to pass it. It'll still fail since it'll generate the configs inside the dbcontext as well and also it will dump the config files into the same directory as the context rather than the configurations directory. Soooo yeah, definitely won't "just work" without alot more effort to make things compatible with it. I could turn off DBContext generation, but then that moves having to deal with generating it instead. I think you're right that a post-processing script might be the best alternative if there isn't a desire to add functionality to the splitting code for now. |
Wonder if the fact that it is set to null is a bug?
Cool! |
Looks like I am composing other namespaces using this, so it is probably by design |
It's weird that the other 2 T4 template types are fine with it being null, but this one isn't. |
Just for other folks who might want to do this in the future (until we have T4 template support for # After a scaffolding event, we want to change the generated Entity Configurations from public to internal.
Param (
[Parameter(HelpMessage="The path within the project where the models reside", Mandatory=$true)]
[string] $ModelsPath,
[Parameter()]
[Switch]
$DryRun
)
# Construct the path to the Models directory
$modelsPath = "${ModelsPath}"
$modelsConfigurationPath = "${modelsPath}\..\Configurations"
# Check if the Models directory exists
if (Test-Path -Path $modelsPath) {
# Update the configuration files to be internal (Until EF Core Power Tools supports T4 Templates for EntityTypeConfiguration)
$files = Get-ChildItem -Path $modelsConfigurationPath -Filter "*Configuration.cs" -File
foreach ($file in $files) {
Write-Host "Updating $($file) to be internal instead of public."
(Get-Content $file) -replace 'public partial class', 'internal partial class' | Set-Content $file
}
} else {
Write-Host "The Models directory does not exist at the path: $modelsPath"
} In my ./tools/Post-Scaffold.ps1 -ModelsPath Models |
Would be nice if we could, via config, change the behavior of
EFCorePowerTools/src/Core/RevEng.Core.60/DbContextSplitter.cs
Line 108 in 2793e2a
internal
instead ofpublic
.Provide technical details
EF Core Power Tools version: 8.1.391
Exact Visual Studio version: NA
Database engine: Azure SQL
EF Core version in use: EF Core 8
Is Handlebars templates used: no
Is T4 templates used: yes
Is a SQL Server .dacpac used: no
The text was updated successfully, but these errors were encountered: