msawczyn/EFDesigner

Namespace collision in generated code

dcastenholz opened this issue · 4 comments

I think that it is common for developers to want to name an entity with the same name as part of the project namespace. Ex: I am currently working on a press release application. The project name is PressRelease. My root namespace is PressRelease as well. It is desirable to have an entity named PressRelease, but the generated code will then have numerous errors due to the collision. In my case, ModelClass.FullName for my Stage enum returns "PressRelease.EntityFramework.Model.Stage". In a number of places, this collides with the PressRelease entity name. If ModelClass.FullName could return "global::PressRelease.EntityFramework.Model.Stage" instead, it would avoid the collision.

I was almost able to work around the issue by changing the transform code, but I ran into ModelAttribute.FQPrimitiveType which can return int, bool, string, etc. in addition to my fully qualified class name. In C#, global::int is invalid. Inside FQPrimitiveType is the line: return modelEnum.FullName;, so fixing ModelClass.FullName should work. I realize that there is an argument to be made that says: "Don't do that!", but I believe that this would be a nice feature.

Thanks for that. I'm looking into it.

The fix you suggest will be in 1.2.7. Thanks for the tip!

1.2.7 pre-release is in the releases. Could you take a peek and see if this resolves your issue? Thanks!

Fixed and released in 1.2.7.1. Closing issue.