How do I remove the database/schema/catalog name from being hardcoded into the model files? I cannot find any setting controlling this. Do I really need to edit template files?
We've been using CatalogNameOverwrites since 2009 but I cannot see any benefit of this compared to the .NET Core way with different connectionstrings in different appsettings and letting the EnvironmentName control things (appsettings.Development|Production.json)
It just seems risky and error-prone to hardcode database name - developers doesn't expect their connectionstring to be overwritten in code.
Perhaps this is because of backwards compatibility? In any case, I hope there's a way to opt out of catalog overwrites? Am I missing something?
CatalogNames are hardcoded to support multiple catalogs in the same project.
You can use CatalogNameOverwrites whether in config files or in code (.net core), and you can provide an empty string for the overwrite value, this will make sure whatever is there in the connectionString will be used.
I guess my question is really, why is the convention that you HAVE to add a catalog overwrites when you have multiple databases?
I'm guessing for historical reasons and backwards compatibility.
It would make more sense to use the .NET Core convention with connection strings in different appsettings.EnvironmentName.json.
Right now, it's easy for new developers to forget to add a catalog overwrite in all scenarios (unit tests, staging, production) - because you trust the catalog name in the connection string - with potentially serious consequences.
Have you considered a project setting that lets you disable hard coding the catalog name? This would solve my problems, unless it would break something else?
In e.g. SQL Server you can specify a catalog to connect to, but once you're connected you can access all catalogs your user has access to. We have the catalog name in the mappings because of multiple catalogs in the mappings and also because the wellformed names in sql server require 3 elements so to avoid problems at runtime in all situations.
Your suggestion of appsettings might look ok in your app, but not everyone creates .net core websites. Our generated code has to work for all apps it's used in, and this is the best way to do this.
You can also specify an empty string for the toName. In that case, the DQE will not specify a catalog name in the generated SQL elements, which will make the SQL target the catalog specified in the connection string.
So if I always set an empty overwrite, the catalog in my connectionstrings will work?