Copied to clipboard

Flag this post as spam?

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


  • Manish 373 posts 932 karma points
    Jul 31, 2017 @ 06:54
    Manish
    0

    How to set GUID as primary key in peta poco apprach

    Hi

    I am using peta poco but no idea how to set primary and foreign key as GUID.

    Thanks

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Jul 31, 2017 @ 08:47
    David Brendel
    100

    Hi Manish,

    on your class you can use an attribute to set your PrimaryKey:

    [PrimaryKey("Id", AutoIncrement = false)]
    

    So your primary key would be named Id and is of type Guid.

    That should work.

    Regards David

  • Manish 373 posts 932 karma points
    Jul 31, 2017 @ 09:07
    Manish
    0

    Many thanks David B :)

  • Manish 373 posts 932 karma points
    Jul 31, 2017 @ 09:32
    Manish
    0

    When I am updating model properties then it is not reflecting directly in table, First I need to delete the old table and run the project then it creates new table with changes. I there any way to migrate changes in table without deleting the table.

    Thanks

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Jul 31, 2017 @ 10:37
    David Brendel
    0

    Hi Manish,

    have a look at umbraco migrations. Basically a class inheriting from MigrationBase.

    With that you have an up/down method where you can do changes on your tables.

    https://cultiv.nl/blog/using-umbraco-migrations-to-deploy-changes/

    Regards David

  • Manish 373 posts 932 karma points
    Jul 31, 2017 @ 12:28
    Manish
    0

    This works only when i create migration script manually but i want the way to create migration script dynamically [add-migration] same as entity frame work in mvc approach. In MVC approach there is an option in manage console to create migration script by [add-migration].

    I want approach something like this https://docs.microsoft.com/en-us/aspnet/mvc/overview/getting-started/getting-started-with-ef-using-mvc/migrations-and-deployment-with-the-entity-framework-in-an-asp-net-mvc-application

    Please suggest on above query.

    Thanks

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Jul 31, 2017 @ 13:22
    David Brendel
    0

    Hi Manish,

    that's not possible in Umbraco. You have to create the migrations by hand.

    Regards David

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies