AnantLabs / codesmith

Automatically exported from code.google.com/p/codesmith
1 stars 0 forks source link

EntityNaming and TableNaming not functioning #644

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I am trying to generate an edmx file using the edmx.cst template. I can set the 
following properties in the template.
CodeSmith.SchemaHelper.Configuration.Instance.NamingProperty.EntityNaming = 
EntityNaming.Plural;
        CodeSmith.SchemaHelper.Configuration.Instance.NamingProperty.TableNaming = TableNaming.Singular;

which will generate the Entity sets with a plural name but the Entity objects 
are plural as well.

I had hoped that this would generate a plural entity set name with a singular 
entity name.

I am using CodeSmith Generator Professional 6.0.2 Revision 14171.

I am new to CodeSmith so if I am going about this wrong please point me in the 
right direction.

Original issue reported on code.google.com by richa...@united-systems.com on 23 Apr 2012 at 8:08

GoogleCodeExporter commented 9 years ago
Hello,

First, I'd recommend upgrading to 6.0.3 as there are many bug fixes in 6.0.3.

I believe that you would only want to set the following only:

 Configuration.Instance.NamingProperty.AssociationTypeNameSuffix = AssociationSuffix.Singular;
            Configuration.Instance.NamingProperty.AssociationSuffix = AssociationSuffix.Plural;

We should expose this in the Outputs so one doesn't have to change the code. 
Please let me know if this resolves the issue.

Original comment by bniemyjski on 24 Apr 2012 at 1:34

GoogleCodeExporter commented 9 years ago
I have upgraded to 6.0.3.

I have attempted to add the properties to my edmx.cst template but I don't have 
 the following property

Configuration.Instance.NamingProperty.AssociationTypeNameSuffix.

Is there a later build of the CodeSmith.SchemaHelper.dll that isn't shipped 
with the Samples in 6.0.3?

Original comment by richa...@united-systems.com on 24 Apr 2012 at 2:57

GoogleCodeExporter commented 9 years ago
Hello,

Yes, please use the following nightly build of EF 
(http://community.codesmithtools.com/nightly/PLINQOEF/plinqo-ef-r2635.zip). 
This contains a few fixes since the version that was included in 6.0.3 and 
contains the methods mentioned above.

Original comment by bniemyjski on 25 Apr 2012 at 7:44

GoogleCodeExporter commented 9 years ago
Please remember to unblock the zip file after you have downloaded it.

Original comment by bniemyjski on 25 Apr 2012 at 7:45

GoogleCodeExporter commented 9 years ago
Thanks for the quick reply. 

I downloaded the nightly build and extracted the zip. This does give me the 
properties I needed for the above example. 

It did not ,however, fix the problem. I still have both Entity Set and Entity 
with a singular name. What I am trying to achieve is a plural Entity Set with a 
singular Entity.

Original comment by richa...@united-systems.com on 25 Apr 2012 at 9:08

GoogleCodeExporter commented 9 years ago
Hello,

You would need to delete your edmx file and regenerate as it is preserving the 
existing name values.

Original comment by bniemyjski on 26 Apr 2012 at 1:10

GoogleCodeExporter commented 9 years ago
Thanks for bearing with me on this. Let me itemize the steps I took in hopes 
that I may be doing something wrong.

1.  Download the nightly build 
(http://community.codesmithtools.com/nightly/PLINQOEF/plinqo-ef-r2635.zip).
2.  Right click the plinqo-ef-r2635.zip and select the properties menu item from 
the context menu.
3.  Click the unblock button. Then select apply and close the properties window.
4.  Extract the plinqo-ef-r2635.zip file.
5.  Edit the Edmx.cst file under the (Plinqo EF\CSharp) directory.
6.  Add the following two properties at line 103.
Configuration.Instance.NamingProperty.AssociationTypeNameSuffix = 
AssociationSuffix.Singular;
            Configuration.Instance.NamingProperty.AssociationSuffix = AssociationSuffix.Plural;

7.  Save the Edmx.cst.
8.  Execute the QuickStart.cst.
9.  Select the Source Database. Leave all other properties at default.
10. Open the Location directory and make sure it is empty (no edmx file).
11. Click the Generate button.
12. Open the .sln with visual studio.
13. Rebuild the .data project to generate the edmx.
14. Open the .edmx in designer.
15. Select an EntityType in designer.
16. Review properties 
    Entity Set Name
    Name
17. Entity Set Name is singular.
18. Name is singular.

What I want is the Entity Set Name to be plural and the Name to be singular.

Original comment by richa...@united-systems.com on 26 Apr 2012 at 3:30

GoogleCodeExporter commented 9 years ago
I will take a look into this. As a work around until I have more information. 
If you manually change the names in the edmx file, they will be preserved.

Original comment by bniemyjski on 27 Apr 2012 at 6:35

GoogleCodeExporter commented 9 years ago
Hello,

I followed your steps to a T but fully qualified Step #6.

        CodeSmith.SchemaHelper.Configuration.Instance.NamingProperty.AssociationTypeNameSuffix = AssociationSuffix.Singular;
        CodeSmith.SchemaHelper.Configuration.Instance.NamingProperty.AssociationSuffix = AssociationSuffix.Plural;

And it worked as expected. I used beyond compare to diff the generated edmx 
files. Do you have a specific table schema you could dumb down that can 
reproduce this naming behavior and I'll create the table (no data needed) to 
debug on my end.

Original comment by bniemyjski on 27 Apr 2012 at 9:49

GoogleCodeExporter commented 9 years ago
My database table names are plural. Were yours?

Original comment by richa...@united-systems.com on 30 Apr 2012 at 7:04

Attachments:

GoogleCodeExporter commented 9 years ago
Yes, some of mine were plural. I was able to restore the database and I'm 
taking a look at this now.

Original comment by bniemyjski on 3 May 2012 at 2:47

GoogleCodeExporter commented 9 years ago
Hello,

Could you please attach your generated edmx file as well as your modified 
edmx.cst file. I followed the steps again and regenerated and I'm getting the 
right results.

I'm getting a singular entity name with plural entity sets.

        <EntityType Name="Size">
          <Key>
            <PropertyRef Name="Identification" />
          </Key>
          <Property Name="Identification" Type="Int32" Nullable="false" p6:IsUnique="True" p7:StoreGeneratedPattern="Identity" xmlns:p7="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns:p6="http://tempuri.org/Attribute" />
          <Property Name="Name" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
          <Property Name="Description" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
          <Property Name="IsDeleted" Type="Boolean" Nullable="false" />
          <Property Name="Concurrency" Type="Binary" Nullable="false" MaxLength="8" FixedLength="true" p6:StoreGeneratedPattern="Computed" xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
          <NavigationProperty Name="BackflowDevices" Relationship="Issue644.Data.FK_BackflowDevices_Sizes" FromRole="Size" ToRole="BackflowDevice" />
        </EntityType>

I'm trying to think what could possibly be different (using same database 
backup, following the same steps). What is the exact revision number of the 
templates you are using?

If we still can't get this worked out, would you be free for a go-to-meeting so 
I could take a look first hand?

Original comment by bniemyjski on 3 May 2012 at 2:57

GoogleCodeExporter commented 9 years ago
I've also created a new issue to make this into a template property 
(http://code.google.com/p/codesmith/issues/detail?id=648).

Original comment by bniemyjski on 3 May 2012 at 3:01

GoogleCodeExporter commented 9 years ago
I am including views. Not sure if this would make a difference or not. I have 
attached the requested files. I a not sure I know what you are asking for on 
the template revision number. I pulled the nightly build plinqo-ef-r2635.zip. I 
am using the templates in this zip to generate the edmx. I will check on the 
possibility of doing the go-to-meeting session.

Thanks again for all your effort on this.

Original comment by richa...@united-systems.com on 3 May 2012 at 8:22

Attachments:

GoogleCodeExporter commented 9 years ago
Hello,

Thanks for attaching those. I diffed your edmx file and settings with mine and 
they were exact (except for the namespace name). What specific entity type are 
you seeing where the naming is incorrect. They all appear to be named 
consistently with your specifications (singular entity name, plural association 
name).

Original comment by bniemyjski on 7 May 2012 at 5:12

GoogleCodeExporter commented 9 years ago
Let me attach a picture and explain what I am seeing.  In the picture the 
Entity Set Name is singular and should be plural. The Name of the entity is 
correct. The associations should be singular or plural based on the 
relationship. If it is a singular object then singular if a collection of 
objects it should be plural.

Thanks again for your help.

Original comment by richa...@united-systems.com on 10 May 2012 at 5:53

Attachments:

GoogleCodeExporter commented 9 years ago
Hello,

Thanks for the clarification, I'm 100% following you with the newly attached 
screenshot. 

We currently do not support naming this and it was an oversight on my part when 
I wrote the templates. I'm marking this issue as invalid for two reasons.

1. I've created a new task (Issue 648) to control property naming to the 
templates (what this issue was initially created for (we were on different 
pages).
2. Could you please log this under a new Issue, with the attached screenshot 
and a name like Ability to control EntitySet container names. I will make sure 
that this gets implemented in the next release of the templates.

Thanks for your time
-Blake

Original comment by bniemyjski on 11 May 2012 at 4:48

GoogleCodeExporter commented 9 years ago
I added the issue: http://code.google.com/p/codesmith/issues/detail?id=650

Original comment by bniemyjski on 17 May 2012 at 2:08