1

TL;DR;
Can you summarise what happens when I instantiate a instance of class that extends EF DbContext???

Long
I want to learn as much as I can about it and only reading the source code is not being very productive because of the various reference to interfaces and abstract classes...

I was hoping that with a step by step, I would be able to more easily identify which part am dealing with...

I would like to contribute with the project and I want to have a sound understanding of everything...

So, can you describe what happens when I instantiate a class such as this one bellow?:

public class ProductContext : DbContext
{
    public DbSet<Category> Categories { get; set; }
    public DbSet<Product> Products { get; set; }
}

edit 1
Let me exemplify the kind of answer i'm looking for, using as a example, "starting a car":
First you insert the key in the socket. Turning the key is actually a 3 steps action. When you turn it just a bit, validating that the key fits the lock and powered by the internal battery, the car starts electrical systems, accounting the amount of gas, turns off external lights like break-lights and headlights, turns off A/C and reverts all the power for a internal electric engine, that will turn the main engine.
if you turn it a bit more, sync systems will fire up, alongside the gas pump and the electrical engine, causing the crankshaft to spin and put the pistons in motion, which is the reverse mode of regular operation. If any gears are "set" the car will move and the main engine start will fail. If not the gas pump will spray gas in the piston chamber, the sync system will cause a spark, exploring the gas, and starting the main engine. After that the electric engine will stop, a transformer will enter in action replenishing the main battery.
If the sync system and gas pump continue to function flawlessly, the ignition in the pistons will continue to happen in a 4-cycle manner and the car will be ready to drive. If not the car will die, and the whole process can be repeated.

Now pls note that although "complete" and "technical" various points were not noted, such as oil, water-cooling, mechanics internals of the engine, gear box and others... but if you are capable of doing so PLS do it!

Leonardo
  • 10,737
  • 10
  • 62
  • 155

1 Answers1

1

I'm not really sure what you're looking for but maybe this information will help. When you instantiate a DbContext class the constructor calls a private method that initializes the DbSet properties. It does this by using an internal class named DbSetDiscoveryService to discover via reflection the DbSet properties in the current class.

Some helpful links:

  • A similar question and answer on SO here.
  • Here is a link to that DbSetDiscoveryService class.
  • Here is a link to the source code for the Entity Framework.
Community
  • 1
  • 1
test
  • 2,589
  • 2
  • 24
  • 52
  • that is helpful but quite not deep enough as i need... or at least, hoping for... – Leonardo Dec 10 '15 at 17:29
  • @Leonardo anything specific I could maybe answer? Having access to the source code means that you can go as deep as you want. – test Dec 10 '15 at 17:30
  • as i mentioned in the long version, the code is not easy to read and understand... figure out "intent" behind code is not a easy task even if you are familiar with the project... I edited my post... check it out – Leonardo Dec 10 '15 at 18:06