How to Extend MainProjectDataContext & use it in RCL project?

Hamed Vaziri 136 Reputation points


I have a blazor server project as my main project with a configured dataContext called forexample : MainProjectDataContext.

Now i have a razor class library project which has a reference to my main blazor server project. in my rcl project i've added some classes as poco (without define any dataContext) to handle database transactions.

Now i have a some questions?

  1. How to extend my MainProjectDataContext in rcl project to handle database transactions for my new classes that i've created in my rcl project?
  2. how to add my new rcl dataContext to service providers & inject it into my razor files (with some options which i've configured in my main blazor server porject such as connectionString, ...)?

I will be grateful if you show with an example code.

Thanks in advance

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
678 questions
A set of technologies in the .NET Framework for building web applications and XML web services.
4,024 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
9,982 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Piyaphart Samutkang 0 Reputation points
    [type here]()
    0 comments No comments

  2. Bruce ( 52,826 Reputation points

    .net does not allow circular references (two projects to ref each other). You should create third project for all shared code.

    0 comments No comments