This is a migrated thread and some comments may be shown as answers.

MsSQL to MySQL schemas to namespaces

1 Answer 68 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mike
Top achievements
Rank 1
Mike asked on 10 Jun 2014, 07:15 PM
Hello,

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:
            implements.AddFirst(codeClass.BaseClass.Name);
with:
            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,
Michael

1 Answer, 1 is accepted

Sort by
0
Boris Georgiev
Telerik team
answered on 13 Jun 2014, 03:43 PM
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.

Regards,
Boris Georgiev
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
Tags
General Discussions
Asked by
Mike
Top achievements
Rank 1
Answers by
Boris Georgiev
Telerik team
Share this question
or