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?
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.
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.
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.
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?
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...
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.
Source code available at: github.com/JasperKent/InMemoryDatabase
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?
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.
Can you use an inmemory database in an actual app to store states (like storing a chess game state) or is that not viable
It's possible, but there's no benefit too it. If you want to store data in memory, just use collections etc.
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.
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.
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?
Yes, AFAIK, the objects are just stored as objects in memory, so there's no need to create a database in any sense.
thank you!
Thank you Professor!
Greatly helpful!
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...
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.
Thank you!!!!
My pleasure.