MsSQL to MySQL schemas to namespaces

Thread is closed for posting
2 posts, 0 answers
  1. Mike
    Mike avatar
    1 posts
    Member since:
    Feb 2011

    Posted 10 Jun 2014 Link to this post


    We are porting a MsSQL database which makes extensive use of schemas.  When the database is transferred from MsSQL to MySQL using the MySQL migration wizard, the naming of the tables change from something like this: lku.MessagePriority to: lku_message_priority.

    We would like to update the code generation to treat the lku_ (first instance of the underscore) as part of the namespace for the generated class.

    We have tried adding some additional code to the ClassGenerator.ttinclude in the GenerateClassSignature method

    replaced line 67:
                var namespace = codeClass.BaseClass.Name.Substring(0, 3);
                var className = codeClass.BaseClass.Name.Replace(namespace, "");
                implements.AddFirst(string.Format("{0}.{1}", namespace, className));

    This works for the classes, but the references to the classes are not correct.

    Which of the ttinclude files can we modify to change the namespaces and class names when the tables definitions are read from the database?

    Thank you,
  2. Boris Georgiev
    Boris Georgiev avatar
    190 posts

    Posted 13 Jun 2014 Link to this post

    Hello Mike,

    Unfortunately you will not be able to implement this changes to the classes and namespaces names through the code generation templates. Even you change the templates the Enhancer will not be able to enhance the classes, because the information in the metadata container will not show any changes.

    So in your case, you can use the default code generation templates and create the classes with the default names. Then open the Model Operation dialog and select manually classes by schema and change their names and namespace.

    I hope that helps.

    Boris Georgiev
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
Back to Top