Entity Framework Core In-Memory Database

Поділитися
Вставка
  • Опубліковано 30 лис 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.

  • @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.

  • @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.

  • @paxvostrum4824
    @paxvostrum4824 2 роки тому +1

    Thank you Professor!

  • @kimcorson4458
    @kimcorson4458 2 роки тому +1

    thank you!

  • @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.

  • @ohaRega
    @ohaRega 3 роки тому +1

    Greatly helpful!

  • @ZackMcColgan
    @ZackMcColgan 4 роки тому +1

    Thank you!!!!