views:

310

answers:

2

Hi,

I got an entity called Proveedor on my Data Context. A property called Proveedors is generated for the Data Context to represent a collection of Proveedor. I rename it to Proveedores which is the correct spelling in spanish. But as soon as i do anything on the model (not related to the Proveedor Entity) and rebuild it renames it back to Proveedors again.

I dont want to turn off pluralization just want it to stop renaming my renames :)

Thanks

A: 

Where are you renaming it? If you change the generated C# code, it will be overwritten just as you've seen.

You need to change it in the dbml file. Open that file. Select the property, and then open the property panel and change it there.

James Curran
I am using the class view and selecting the DataContext then scrolling down to its properties, right click on the property and select Rename, this does a replace on the code. Its the mos eficient way of doing it I have found so far. I cannot find a way to do it from the Properties window.
Luis
@Luis: Yeah you can't do it in the designer. You'll have to edit the properties of it from the .dbml or else make some changes with partial classes
@Jack Thanks, it seems I will have to set up my .dbml completely and then rename this entity and it will hold.
Luis
+1  A: 

When you make a change to the data model dbml file, the Linq to SQL classes are generated completely from scratch. Any modifications you make to the class files will be overwritten.

Changing the pluralization rules would have to be done by changing the code generation, but I do not know if this is possible.


You can change the generated name by right-clicking the table in the dbml designer window and selecting properties. There is a field called 'name' with which you should be able to define a custom name.

Also: this is not directly relevant to this particular issue, but if you want to add modifications to the generated classes, they are defined as partial classes. So you could add methods to the classes by creating a separate partial class.

Adam Lassek
Thanks for verifying my suspicions.
Luis