Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update to EF 7.0.0-rc1-final broke SQL DbContextOptionsBuilder UseSqlServer

I just updated my nuget package to EF 7.0.0-rc1-final from a previous EF 7 version it has broke my sql connection string code.

using System.Collections.Generic;
using ComicEndpoints.Models;
using System.Threading.Tasks;
using Microsoft.Data.Entity;
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
    options.UseSqlServer(@"ConnectionString");
}

The Error:

The Type 'DbContextOptionsBuilder' is defined in an assembly that is not referenced. You must add a reference to assembly 'EntityFramework.Core, Version 7.0.0.0'

I have installed EntityFramework.Core to the latest version in NuGet but I cannot seem to reference it with 'using'. This just occurred when updating to rc1-final and I cannot find any documents referencing the change.

project.JSON

{
  "webroot": "wwwroot",
  "version": "1.0.0-*",

  "dependencies": {
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "EntityFramework.SqlServer": "7.0.0-beta8",
    "EntityFramework.SqlServer.Design": "7.0.0-beta8",
    "EntityFramework.Commands": "7.0.0-rc1-final",
    "Microsoft.Framework.Configuration.Json": "1.0.0-beta8",
    "Newtonsoft.Json": "8.0.1-beta2",
    "EntityFramework.Core": "7.0.0-rc1-final"
  },

  "commands": {
    "web": "Microsoft.AspNet.Hosting --config hosting.ini",
    "ef": "EntityFramework.Commands"
  },

  "frameworks": {
    "dnx451": {
      "dependencies": {
        "Microsoft.AspNet.WebApi.Cors": "5.2.3",
        "Microsoft.Owin.Cors": "3.0.1"
      }
    },
    "dnxcore50": { }
  },

  "exclude": [
    "wwwroot",
    "node_modules",
    "bower_components"
  ],
  "publishExclude": [
    "node_modules",
    "bower_components",
    "**.xproj",
    "**.user",
    "**.vspscc"
  ]
}
like image 566
AndrewBrntt Avatar asked Nov 19 '15 20:11

AndrewBrntt


People also ask

What is dbcontextoptionsbuilder in SQL Server?

UseSqlServer<TContext> (DbContextOptionsBuilder<TContext>, String, Action<SqlServerDbContextOptionsBuilder>) Configures the context to connect to a Microsoft SQL Server database. The type of context to be configured. The builder being used to configure the context. The connection string of the database to connect to.

How do I use Entity Framework dbconnection?

Entity Framework Core Configures the context to connect to a Microsoft SQL Server database, but without initially setting any DbConnection or connection string. The connection or connection string must be set before the DbContext is used to connect to a database. Set a connection using SetDbConnection (DatabaseFacade, DbConnection) .

Does EF Core support bulk updates?

While all changes are done in a single roundtrip thanks to batching, EF Core still sends an UPDATE statement per employee, which must be executed by the database. Relational databases also support bulk updates, so the above could be rewritten as the following single SQL statement:

Is there a sample code for insertorupdate method in EF Core?

The Disconnected entities article linked above also includes sample code for a homemade InsertOrUpdate method, for earlier versions of EF Core or if the entity doesn't have an auto-generated key. The sample code is specific to a particular entity class and would need modification to make it generalized. I think this is what you want.


1 Answers

I believe the name has also changed on this:

'EntityFramework.SqlServer': "7.0.0-rc1-final'

-- it is now:

'EntityFramework.MicrosoftSqlServer': "7.0.0-rc1-final'

See post: Upgrading ASP.NET 5 Beta 8 to RC1

TIP: Download the Asp.Net Docs from GitHub and see how they (ASP.NET Authors) are coding the references and dependencies...

like image 141
SRQ Coder Avatar answered Nov 02 '22 04:11

SRQ Coder