Skip to content
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

[Bug] Model Imports wrongly generated when EnableSchemaFolders = true when contextNamespace and modelNamespace are same or blank #214

Open
tejasvih opened this issue Aug 2, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@tejasvih
Copy link

tejasvih commented Aug 2, 2022

Describe the bug
Imports are wrongly generated (e.g. using masters = .masters) in context file when EnableSchemaFolders = true in options but either namespace is not provided or its same for context and model.

Expected behavior
It should generate namespace as
using <schema> = <modelNamespace>.<schema>
or
using <modelNamespace>.<schema>

To Reproduce
Using PostgreSQL with

Scaffold-DbContext Name=<connection string> Npgsql.EntityFrameworkCore.PostgreSQL -Namespace SomeAPI.DbModels -ContextNamespace SomeAPI.DbModels -o DbModels

or

Scaffold-DbContext Name=<connection string> Npgsql.EntityFrameworkCore.PostgreSQL -o DbModels

Make My Life Easier
This seems to be happening due to this condition , which is not assigning value to _modelNamespace when both namespace are same
File: HbsCSharpDbContextGenerator.cs
Method: WriteCode(..)

if (!string.IsNullOrEmpty(modelNamespace) && string.CompareOrdinal(contextNamespace, modelNamespace) != 0)
                _modelNamespace = modelNamespace;
@tejasvih tejasvih added the bug Something isn't working label Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant