Configuration file for Microsoft EntityFrameworkCore

0
0

Dear

Its there someone experience how use Microsoft Entity Framework Core in Wisej (i am using wisej 4).

When i run command “Scaffold-DbContext ‘Name=cmisconString’  Microsoft.EntityFrameworkCore.SqlServer”

there error “A named connection string was used, but the name ‘cmisconString’ was not found in the application’s configuration.”

 

Based Microsoft tutorial , “cmisconString” (connection string) must put in file “appSettings.json” (there no this file in wisej ). Which file configuration in wisej than support microsoft entity framework core ??.

 

This what i had to do: (connectionvalue = “Data Source=localhost;Initial Catalog=cmis;User ID=cmis;Password=cmis;Encrypt=False;Trust Server Certificate=True;”)

  1. Add “cmisconString” in web.config  (same error)

    <ConnectionStrings> <add key=”cmisconString” value=”connectionvalue”/></ConnectionStrings>

  2. Add “cmisconString” in Default.json (same error)

    “cmisconString” : “connectionvalue”

  3.   Add “cmisconString” in launchSettings.json (same Error)

    “ConnectionStrings”: {
    “cmisconString”: “connectionvalue”
    }

  4. Add file appSettings.json in wisej with connection string base on microsoft tutorial

    in this way  i am successfull running command “Scaffold-DbContext “, but when i want call model in DbContext, there appear the same error.

 

There no problem when i using an connection without connectionstring alias.

Thanks

 

Nicky

 

 

 

 

  • You must to post comments
0
0

Hi Nicky,

You can use the appSettings.json approach like you mentioned above, however if you’re running into issues with running queries on the DBContext, then it could be an issue of how you’re injecting the service into the Service Container.

I recommend heading to our documentation about Dependency Injection.

Can you wrap a small runnable sample that would showcase the issue?

Best Regards,
Alaa

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.