Register a Context with dependency injection container in Blazor Application

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
gstenstrom
Posts: 1
Joined: Wed 10 Mar 2021 17:56

Register a Context with dependency injection container in Blazor Application

Post by gstenstrom » Wed 10 Mar 2021 18:08

I have a MS SQL Server database which I have built a LinqConnect Model on top of. I am learning .NET COre and specifically Blazor. I cannot figure out how to register the context with my .NET Core Blazor application in the startup.cs.

The following results in a type conversion error. "There is no implicit reference conversion from MyLinqConnectDBCtx to Microsoft.EntityFrameworkCore.DbContext".

Code: Select all

public void ConfigureServices(IServiceCollection services)
{
     services.AddDbContext<MyLinqConnectDBCtx>(options => options.UseSqlServer(connstring)); 
}
I have looked everywhere and can find no guidance on this at all. It means it's probably something dumb on my part but I got no idea what to try at this point.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Register a Context with dependency injection container in Blazor Application

Post by Shalex » Fri 12 Mar 2021 16:28

You should create Devart EF Core Model *.efml (product Entity Developer for Entity Framework) instead of Devart LinqConnect Model *.lqml (product LinqConnect) to follow the tutorials like this one: https://docs.microsoft.com/en-us/aspnet ... etcore-5.0.

Post Reply