-
-
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
Adding Trim option in Reverse Engineer tool #300
Comments
I modified my context to add this to all columns, but then had them removed when a new table was added through the tool. |
May I offer an alternative? public override int SaveChanges(bool acceptAllChangesOnSuccess)
{
UpdateEntityValues();
return base.SaveChanges(acceptAllChangesOnSuccess);
}
public override Task<int> SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken = default)
{
UpdateEntityValues();
return base.SaveChangesAsync(acceptAllChangesOnSuccess, cancellationToken);
}
public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = default)
{
UpdateEntityValues();
return base.SaveChangesAsync(cancellationToken);
}
private void UpdateEntityValues()
{
foreach (var entity in ChangeTracker.Entries())
{
foreach (var property in entity.Properties)
{
if (property.IsModified && property.CurrentValue.GetType() == typeof(string))
{
// Trim happens here
property.CurrentValue = property.CurrentValue.Trim();
}
}
}
} |
That works for mutations, but not querying. I'm using this to generate a model on a vendor database and they have the columns set to char instead of varchar. |
Just add a partial DbContext class, and implement the partial OnModelCreatingPartial method. Maybe I should add this to the docs?
|
I like that approach! Doing it that way allows me to code the relationships that were missed to! Thanks! |
Docs updated |
Can an option be added to append the following to all columns generated by using the Reverse Engineer tool to trim all leading and trailing spaces?
The text was updated successfully, but these errors were encountered: