My solution consists of two projects:
DataAccess) that defines a class (named as MyContext) inheriting from DbContext. As DbContext is defined in EntityFramework.dll assembly, I need to add a reference to this assembly into this class library project. I have no confusion in this mechanism.Tester) that consumes the DataAccess class defined in the class library above. Adding a reference to the assembly of the class library above is understandable. Unfortunately, I cannot compile the solution until I add a reference to EntityFramework.dll into this console application.Why do we need to add a reference to an assembly, from which a class library project inherits, into a consumer project?
In my mental model, it is enough to only add a reference to DataAccess project assembly into Tester project and the chained references should be done automatically.
Because otherwise EntityFramework.dll wont get copied to the output directory when you build your project and your library won't be able to access it.
If you are able to embed EntityFramework.dll into your library (right click the reference -> Properties) then you won't need to reference it on your console application.
Because a lot of the behaviour in MyContext is inherited from the base class in entity framework. If you call those methods (e.g. SaveChanges()) from Tester, the Tester app needs a reference to the class library where the method is defined.
If you would only access methods of MyContext that are defined in your class library, I think you could do without the reference to the base class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With