none
Linq to SQL Designer Question RRS feed

  • Question

  • Hi All. My question is the follow:

    I use visual studio 2008 sp1 and sqlexpress 2008. In the server explorer i have all tables of my db, all written in a PLURAL way, for example

    (Customers, CustomersRegions,...), now When i do a drag and drop operation of any table from server explorer to linq to sql designer, this

    designer truncate  the table Name and the last char("s") dissapear. so intead of customers after drag and drop appear Customer.

    How do I to customize linq designer to avoid this issue? I don´t want the designer truncates the last char, i want to keep the original names

    of all tables. Thanks in advance

     

     

    Friday, September 3, 2010 6:26 AM

Answers

  • just rename the entity again and add the letter s to the end, it works
    • Proposed as answer by Ali Hamdar Friday, September 3, 2010 12:04 PM
    • Marked as answer by liurong luo Wednesday, September 8, 2010 11:47 AM
    Friday, September 3, 2010 6:34 AM
  • Hi

    DBML file uses naming for the generated classes by default

    if you have Customer and Invoice tables in the database, then you know that in the dbml you will get entity Customer and entity Invoice

    inside Customer you will get EntitySet ( Invoices ) !!! which is a set of Invoice Object, and imagine you have an object called Invoices, not logical

    and inside Invoice table you will get EntityRef ( Customer) and this is the correct naming because each customer might has set of invoices and each invoice is for one customer

    this because the generated classes are objects, and this is the correct way to name the objects

     

    hope this help you

    regards

    • Marked as answer by liurong luo Wednesday, September 8, 2010 11:46 AM
    Sunday, September 5, 2010 11:24 AM
  • Hmm, when you add a new datasource, I think the option is there in one of the dialog boxes, in the command line generating tool is "/p", in the IDE.

    http://msdn.microsoft.com/en-us/library/bb384507.aspx

    Regards

    • Marked as answer by liurong luo Wednesday, September 8, 2010 11:46 AM
    Tuesday, September 7, 2010 12:07 PM

All replies

  • just rename the entity again and add the letter s to the end, it works
    • Proposed as answer by Ali Hamdar Friday, September 3, 2010 12:04 PM
    • Marked as answer by liurong luo Wednesday, September 8, 2010 11:47 AM
    Friday, September 3, 2010 6:34 AM
  • Sure, but I have 53 tables in my db, and I don't want to rename one to one when I do a drag and drop operation, because we are working in a team, so I don´t know what changes have been done by others developers to db, so when i do any change in db i have to delete all tables and stored procedures in the designer and then I do the drag and drop. 

    Therefore when anybody of our team do a change all tables are renamed :-(

    Friday, September 3, 2010 12:10 PM
  • You can actually tell them if you want to pluralize or singularize the names, is in the ORM/IDE somewhere.

    The most interesting question is why are your tables in plural?

    Regards

    Friday, September 3, 2010 12:42 PM
  • Hi Serguey, all collection of data (tables) are in plural. We use this criteria for all database design. I know anybody (dr sql for example)  says that this criteria is not a good practice, but it is an old practice, so we keep it in our way of work.

    I can't find anywhere of ORM/IDE that allows me to change this behavior.

    Thanks

    Sunday, September 5, 2010 8:37 AM
  • Hi

    DBML file uses naming for the generated classes by default

    if you have Customer and Invoice tables in the database, then you know that in the dbml you will get entity Customer and entity Invoice

    inside Customer you will get EntitySet ( Invoices ) !!! which is a set of Invoice Object, and imagine you have an object called Invoices, not logical

    and inside Invoice table you will get EntityRef ( Customer) and this is the correct naming because each customer might has set of invoices and each invoice is for one customer

    this because the generated classes are objects, and this is the correct way to name the objects

     

    hope this help you

    regards

    • Marked as answer by liurong luo Wednesday, September 8, 2010 11:46 AM
    Sunday, September 5, 2010 11:24 AM
  • Thanks Hadi.

    You are fix my issue.

    Sunday, September 5, 2010 11:26 AM
  • Sure, but I have 53 tables in my db, and I don't want to rename one to one when I do a drag and drop operation, because we are working in a team, so I don´t know what changes have been done by others developers to db, so when i do any change in db i have to delete all tables and stored procedures in the designer and then I do the drag and drop. 

    Therefore when anybody of our team do a change all tables are renamed :-(


    I have an add-in that may help you: it can do rule-based mass renaming of L2S entities, members, stored procs etc. You can download the add-in and get a trial license from http://huagati.com/dbmltools/
     
       Cool tools for Linq-to-SQL and Entity Framework 4:
     huagati.com/dbmltools - Rule based class and property naming, Compare and Sync model <=> DB, Sync SSDL <=> CSDL (EF4)
     huagati.com/L2SProfiler - Query profiler for Linq-to-SQL and Entity Framework v4
    Monday, September 6, 2010 2:02 AM
    Answerer
  • Hmm, when you add a new datasource, I think the option is there in one of the dialog boxes, in the command line generating tool is "/p", in the IDE.

    http://msdn.microsoft.com/en-us/library/bb384507.aspx

    Regards

    • Marked as answer by liurong luo Wednesday, September 8, 2010 11:46 AM
    Tuesday, September 7, 2010 12:07 PM
  • Thanks Serguey

    It is just what i am looking for

    Tuesday, September 7, 2010 2:03 PM
  • Glad to be of service, if a post solved your problem you should mark it as the answer, if a post was helpful toward it you should mark it as helpful.

    It is courtesy and will help others that may encounter the same problem find the solution quicker.

    Remember, we do this because of the simple pleasure of helping others and bettering ourselves.

    Regards

    Tuesday, September 7, 2010 2:28 PM