Posts

Showing posts with the label entity-framework-core

Entity Framework core : DbContextOptionsBuilder' does not contain a definition for 'usesqlserver' and no extension method 'usesqlserver'

Entity Framework core : DbContextOptionsBuilder' does not contain a definition for 'usesqlserver' and no extension method 'usesqlserver' I'm new to EF core and I'm trying to get it to work with my asp.net core project. I get the above error in my startup.cs when trying confiugure the dbcontext to use a connection string from config. I'm following this tutorial : https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/intro startup.cs The problematic 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 { // This metho...

Proper way to set mutiple AddDbContext() options?

Proper way to set mutiple AddDbContext() options? I have my site solution split into multiple projects, one of which has the classes for the Database. When I tried to generate the first migration I get the following error: Entity Framework Core 2.0.3-rtm-10026 initialized 'SiteDBContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None Change your migrations assembly by using DbContextOptionsBuilder. E.g. options.UseSqlServer(connection, b => b.MigrationsAssembly("")). By default, the migrations assembly is the assembly containing the DbContext. Change your target project to the migrations project by using the Package Manager Console's Default project drop-down list, or by executing "dotnet ef" from the directory containing the migrations project. Your target project '' doesn't match your migrations assembly ''. Either change your target project or change your migrations assemb...