Je suis nouveau à l'EF de base et je vais essayer de le faire fonctionner avec mon asp.net projet de base.
J'obtiens l'erreur ci-dessus dans mon startup.cs
lors de la tentative confiugure la dbcontext utiliser une chaîne de connexion de config. Je suis en suivant ce tutoriel : https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/intro
Le code posant problème au démarrage.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
{
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
services.AddSingleton<IConfiguration>(Configuration);
string conn = Configuration.GetConnectionString("optimumDB");
services.AddDbContext<tracContext>(options => options.usesqlserver(conn));
}
L' usesqlserver
méthode est reconnu si je l'ai mis directement dans le contexte :
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");
}
Tous mes le domaine de la recherche en ligne points de références manquantes, mais je n'arrive pas à trouver celui qui me manque(voir l'image).références
Toute aide serait grandement appréciée,
Merci