3. Configure Entity Framework
This step is optional, however it gives you amazing features allowing to work with your data directly from visual studio code editor and search tables by their class names. It is recommended to first check if all data has been correctly loaded without entity framework mappings, because this step is little bit more complicated due to fact that every project is completely different and it is difficult for us to test every possible scenario, but we will work hard to accomplish this. This is also reason why we encourage people to test if this extension works for you before buying premium licence.
This step is separated because it is good to know in case of error if it is related with this step or the previous one(especially if you are configuring this extension for the first time). To select dbContext you have to open 'Configuration' modal window again(from context menu in code editor). Then you need to switch to second tab 'DbContext'. There is a list of all dbContexts within solution. To select one of them click on 'Select' button next to choosen dbContext and click 'Save/Reload'.
After few seconds you will get following error message ‘Missing specialized DbContext constructor’
, click ‘Details’ button and you will see similar code snippet. You can copy this snippet, then open your db context class and paste it there.
What we are doing right now is very important to understand. When we reloading entity framework class mappings we need to create instance of your db context to extract those mappings, but we don’t want to create your ef context with default constructor, because there might be some logic or strategy to drop and recreate database etc. we don’t want to do any of this. Therefore you need to have constructor overload like the one in the snippet, so we can call this specific constructor with connection string selected on previous tab and logic which you know is correct for this step. Please have in mind that provided snippet is only a hint of how it should look like, you may need to perform some changes to this code for example you might not be inheriting directly from entity framework db context but your own base class which don’t have constructor with string parameter. As you can see there is also a NOTE section which you might need to uncomment if you encounter a mentioned error.
After adding specialized constructor, we need to build our solution because we need new version of assembly with modified db context. This step is only required if we are using entity framework db context mappings. Now we can open configuration window again and reload data.
That’s it! As you can see all data has been loaded and you are ready to work with Netverest tools. It was very fast process, moreover you need to perform it only once per solution, so next time when you open solution everything will be already configured.