5

I try to create a Razor Class Library which I will be able to use in various projects. I need the Razor Class Library to have it’s own entity framework entities. I want to set up the solution somehow so that the Razor Class Library will use the dbcontext of the main web application. I googled but I did not find a way to implement it.

I want the Razor Class Library to be reusable so that I will only need to add the reference and add a migration in the main web application and everything will be ready to use.

Can someone suggest me how to setup the solution in order to make it work?

pitaridis
  • 2,801
  • 3
  • 22
  • 41
  • Did you happen to find a working solution? I was thinking about containing a DBContext and inheriting from it, but this will likely break if you have multiple RCLs with different requirements to the DB. – Beltway Jul 08 '21 at 07:49
  • No I did not find a way to implement it. I just created a class library project for the dbcontext and I referenced this project to both Razor Class Library and Main project. – pitaridis Jul 22 '21 at 06:02

0 Answers0