Custom DDL Templates for Visual Studio 2010
I was wondering if anyone knows of some good community distributed custom DDL templates for Entity Framework 4.0. The default DDL to S开发者_如何学JAVAQL10 Works well enough, but we're looking to do some customization to the naming convention that it just isn't offering us.
I'm not really finding many samples out there of people doing this, so I was hoping someone might know of a resource I'm overlooking (perhaps I am searching for it wrong, or misunderstanding how the whole process works)
Specifically we're wanting to change up how it writes out fields from relationships. For instance, the default template puts in..
tablename_propertyendpoint_propertyname.
We're wanting to find tune this to our naming scheme a little more. And none of us can quite figure out where in the .tt files it is doing this exact behavior.
One of the more specific problems I am trying to solve is how it appends and changes property names in the database. For example..
Products
-------
Id (int)
Name (varchar(32))
Customers
-------
Id
Name
Carts
-------
Id
Customer (fk)
Baskets
-------
Cart (fk) (pk)
Product (fk) (pk)
Assuming this is my object structure... It would look much like listed above. but the database generator expresses it like this..
Products
-------
Id (int)
Name (varchar(32))
Customers
-------
Id
Name
Carts
-------
Id
Customer_Id (fk)
Baskets
-------
Cart_Id (fk) (pk)
Product_Id (fk) (pk)
Now, I realize this doesn't actually 'hurt' anything; but consistency is kind of important to me, and this is a good place to 'learn' how all of this code is generated. I basically wish to design it so that it does not change the names of my fields on me.
Absolutely - you can download the entity designer database generation power pack here: http://visualstudiogallery.msdn.microsoft.com/en-us/df3541c3-d833-4b65-b942-989e7ec74c87
The problem with column names is that they are needed in two places: In the MSL and in the SSDL, and that is where they are generated. So, your easiest bet is to take the MSL and SSDL T4 templates and look at those.
精彩评论