Copied to clipboard

Flag this post as spam?

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


  • Ross Ekberg 124 posts 365 karma points
    Feb 02, 2023 @ 18:58
    Ross Ekberg
    0

    Umbraco 8 Entity Framework

    How does one go about incorporating the entity framework into Umbraco 8?

  • Roy Berris 89 posts 577 karma points c-trib
    Feb 03, 2023 @ 08:32
    Roy Berris
    0

    Umbraco does not use entity framework in version 8. (Nor in 9+ versions thus far).

    You can set-up a entity framework database for your own things alongside Umbraco. Just follow the guides on Microsoft's documentation.

    You should be able to use the same database server as Umbraco, but do not use the same database.

    https://learn.microsoft.com/en-us/ef/ef6/get-started

  • Mateusz Kotwica 29 posts 129 karma points
    Apr 12, 2023 @ 15:02
    Mateusz Kotwica
    0

    I know that the topic is a bit old, but in my application I try to use Entity Framework as an ORM for my custom tables. Roy, could you explain why using the same database server is not a good idea?

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Apr 12, 2023 @ 15:36
    Huw Reddick
    0

    He actually said,

    You should be able to use the same database server as Umbraco

    but do not use the same database.

  • Mateusz Kotwica 29 posts 129 karma points
    Apr 12, 2023 @ 15:50
    Mateusz Kotwica
    0

    I was in a hurry so of course I worded the question wrong... silly me...

    I meant to ask: why I should not use the same database?

    Sorry for the confusion!

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Apr 12, 2023 @ 17:11
    Huw Reddick
    0

    You can if you want, it really depends on what you are going to be storing and how it will be used to be honest, for anything largish that has frequent activity best practice would be to use another database if possible

  • Roy Berris 89 posts 577 karma points c-trib
    Apr 13, 2023 @ 07:23
    Roy Berris
    1

    Hi, it more preference than that you can't. I worded it like that a couple of months ago because it really is a bad practice in general. So why?

    • Separation of concerns, using the same database might seem convenient, maybe even referencing some umbraco tables. Umbraco will change, your code has to change along. Separating concerns will likely increase the lifespan of your application and reduce the difficulty in upgrading.
    • For security reasons; Umbraco has it's own tables and things it need. Data you might want to split this from your own data to make sure it stays secure. Especially when using a different ORM. Your database might require different roles and users for example.
    • Migrating. You don't want your tables to be collateral on an Umbraco upgrade. Not saying it happens right now. But it can, definitely if they decide to go to EF Core. Using code first from the sources of two products on one database not a good idea.
    • Performance. Splitting your database would allow you to scale your database with it's usage aside from the CMS. This is a more advanced subject and 90% of Umbraco sites won't meet the traffic for requirements like this.

    Not every dot is as import to you as it might be to me. And we can probably add more bullets. But it is just a bad practise in general which usually has many reasons.

    So moral of the story, don't bind your data to another application even if it is a as good designed CMS as Umbraco. Don't be subject to the butterfly effect.

  • Drew Mayo 27 posts 128 karma points
    Apr 12, 2023 @ 18:24
    Drew Mayo
    0

    To add --- you might also have other existing databases you need to tie into an Umbraco site. Mine has several and I use EF to connect to those databases and marry up data with Umbraco data (where needed) in the code.

  • Mateusz Kotwica 29 posts 129 karma points
    Apr 13, 2023 @ 08:24
    Mateusz Kotwica
    0

    Thank you all for your input and clarification!

Please Sign in or register to post replies

Write your reply to:

Draft