I am new to EF core and I am trying to get it to work with my main asp.net project.
I get the above error in my startup.cs when trying to confiugure dbcontext to use the connection string from config. I follow this guide: https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/intro
Problem code in startup.cs:
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.SpaServices.Webpack; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.EntityFrameworkCore; using tracV2.models; using tracV2.data; namespace tracV2 { public class Startup {
The usesqlserver method usesqlserver recognized if I put it directly in the context:
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; namespace tracV2.data { public class tracContext : DbContext { protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer("myrealconnectionstring"); }
All my online search queries point to missing links, but I can’t find which one is missing (see image). links
Any help would be greatly appreciated.
thanks
asp.net-core entity-framework-core
Maxime laflamme
source share