Entity Framework Core In-Memory Database

Поделиться
HTML-код
  • Опубликовано: 27 ноя 2024

Комментарии • 16

  • @CodingTutorialsAreGo
    @CodingTutorialsAreGo  4 года назад +1

    Source code available at: github.com/JasperKent/InMemoryDatabase

  • @sajadzargar.dev8
    @sajadzargar.dev8 Год назад +1

    Great video! I haven't seen any tutor here in youtube using in-memory DB to mock the application's dbContext. They usually use Moq for that purpose. Could we say that they practically do the same thing in the case of unit-testing?

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo  Год назад +1

      They do similar things, but the key difference for me is that using the in-memory DB you get the best simulation of whether you've got your includes correct.

  • @RayanMADAO
    @RayanMADAO Год назад +1

    Can you use an inmemory database in an actual app to store states (like storing a chess game state) or is that not viable

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo  Год назад

      It's possible, but there's no benefit too it. If you want to store data in memory, just use collections etc.

  • @ankitjain917
    @ankitjain917 4 года назад +1

    I am not getting the identity column property value, after saveChanges() is called while unit testing. is it because it's not a primary key? or what can be the possible reason.

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo  4 года назад

      If it's not the primary key, than that certainly would be an explanation. The primary key property on the entity class should either be called 'Id' or 'ClassNameId'. If neither of these, it needs the '[Key]' attribute.

  • @piotrjan2927
    @piotrjan2927 2 года назад +1

    Very interesting. I wonder thought how the structure of Model is created in the in-memory database. It does not look like we need to run any migrations. Is it just inferred from DBContext class and Entity classes?

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo  2 года назад

      Yes, AFAIK, the objects are just stored as objects in memory, so there's no need to create a database in any sense.

  • @kimcorson4458
    @kimcorson4458 2 года назад +1

    thank you!

  • @paxvostrum4824
    @paxvostrum4824 2 года назад +1

    Thank you Professor!

  • @ohaRega
    @ohaRega 3 года назад +1

    Greatly helpful!

  • @IBITZEE
    @IBITZEE 3 года назад +1

    Very interesting...
    ?how is implemented internally the "in-memory database"? with ADO.net??
    can you please remake this video without ASP.net... just output to console...
    building the same code with .net 5.x... and explaining it step by step...

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo  3 года назад

      I've no idea how it works internally.
      I try to mix up the application types I use, but think there's enough information there to infer how to make it worth in other application types.

  • @ZackMcColgan
    @ZackMcColgan 4 года назад +1

    Thank you!!!!