Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Amna Butt 20 posts 140 karma points
    Apr 12, 2017 @ 14:17
    Amna Butt
    0

    Create new table in umbraco database from package

    How can I create a custom table in umbraco CMS from a package?

    I wanted to create a table in umbraco CMS where I will save my License key and other key values. Please help in this regard or any other way to save License keys in Umbraco against the package?

  • Carlos Mosqueda 240 posts 431 karma points
    Apr 12, 2017 @ 17:55
    Carlos Mosqueda
    0

    Hi @Amna,

    Have you looked at the MVC code first approach and the Entity Framework would work perfectly for this. Using DBContext you can do some processes to Create or Drop tables or a table for your package. Typically when you use the code first approach, the package would run or gets installed, check for an existing table, if exists, skip, if it doesn't exist, create the table.
    Most likely you will include the compiled DLL in your package to create the table on install. You should look for the install and uninstall methods for Umbraco packages, because you want to use those to create your DBContext methods, but also if someone uninstalls you package, you want to follow the uninstall process to remove the table as well instead of leaving it.

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Apr 12, 2017 @ 18:03
    Dave Woestenborghs
    0

    Hi Amna,

    You can use the migrations framework in Umbraco it self to do this.

    Have a look at this blog post : https://cultiv.nl/blog/using-umbraco-migrations-to-deploy-changes/

    That explains it very well.

    Dave

Please Sign in or register to post replies

Write your reply to:

Draft