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

Update Schema to match Database

5 Answers 108 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.
Jessica
Top achievements
Rank 1
Jessica asked on 15 Feb 2012, 05:13 PM
http://www.telerik.com/community/forums/orm/general-discussions/update-database-schema.aspx 

The code you provided in the above thread updates the Database to match the Project Model.
string ddlScript = handler.CreateUpdateDDLScript(null);
handler.ExecuteDDLScript(ddlScript);

How do I update my rlinq to match the database I am connecting to at runtime?
check for new tables/columns in the database and update the rlinq at runtime to include those new items.


Thanks,

5 Answers, 1 is accepted

Sort by
0
Ivailo
Telerik team
answered on 16 Feb 2012, 12:57 PM
Hi Jessica,

While you are able to define artificial types without them being presented in your rlinq Domain Model at design time, unfortunately reading additional tables at runtime is not possible with the current release of OpenAccess ORM.  We will be glad if you can share your scenario that requires such functionality - maybe we will be able to provide another solution?

I am looking forward to your feedback.

Regards,
Ivailo
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Jessica
Top achievements
Rank 1
answered on 16 Feb 2012, 02:07 PM
I had submitted a sales feedback ticket ( Ticket ID: 511443) in which I was told Yes OpenAccess ORM supports new Columns and new tables.
So which is it?
0
Ivailo
Telerik team
answered on 16 Feb 2012, 03:09 PM
Hello Jessica,

I am sorry for the misunderstanding. Let me clarify what is supported and what is not:

- You can create classes and properties during runtime and define the mapping
- You can create tables based on the new classes and properties using the method for creating and executing DDL scrip
- You cannot get automatically the schema changes from the database during runtime. This is something you can only handle manually if it is necessary to be performed. After that, based on what you read from the database you can use the above mentioned capabilities to define your classes and mapping.

I hope this helps and you are able to implement your scenarios using the current functionality. In any case, do not hesitate to contact us for further assistance.

All the best,
Ivailo
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Jessica
Top achievements
Rank 1
answered on 16 Feb 2012, 03:32 PM
So just to be sure:
Currently I am able to determine what New Tables exist in the Database and what tables have extra Columns than what I have defined in the rlinq.

With that information I should be able to create new Classes for the New tables and add new columns to existing class at run time.

Is that correct?

If so can you provide pointers as to where to begin? Would I use the Fluent API? I have tried to follow the documentation but don't really know where to begin?

Thanks for your help.
0
Ivailo
Telerik team
answered on 16 Feb 2012, 05:17 PM
Hi Jessica,

We do not offer an API for retrieving the database schema, nor an API that is comparing the results of that retrieval with the schema information available in the Domain Model. This is something that is currently supported only during design time. If you need such functionality, you would have to implement it manually.

If you do implement this functionality according to your needs, you can use our Fluent API to define classes and map them to tables. You can achieve that using one of the following approaches:

1) You can use the rlinq file for the tables you already know about. There are two major approaches for presenting the rlinq model into code:
1.1) Using the standard Xml/Attributes mapping - in this case you will have an auto-generated OpenAccessContext only and you will have to add manually a FluentMetadataSource implementation with a PrepareMapping method as shown in the article
1.2) Using the new Fluent Mapping Code Generation available in the Q1 2012 release, which will directly generate the Fluent API code, which you will have to only enhance in order to be able to add your classes at runtime

2) You can directly start with a Code-Only implementation (using Fluent API). In this case you won't be using a visual designer at all - all the classes will be defined in your code (both the existing ones and the dynamically added ones). After that, like in case 1.2, you will just have to enhance the fluent mapping code with some functionality for dynamically adding types, as shown in the artificial types documentation.

Let me know if you need any clarifications or you have other questions.

Greetings,
Ivailo
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
General Discussions
Asked by
Jessica
Top achievements
Rank 1
Answers by
Ivailo
Telerik team
Jessica
Top achievements
Rank 1
Share this question
or