#

 

 

Problem: beim Hochladen der Code First  Daten auf einen SQL Server mit Entity Framework kommt die Meldung

PM: Add-migration initial

Unable to create an object of type 'app_DbContext2'. Add an implementation of 'IDesignTimeDbContextFactory<app_DbContext2>' to the project

 

 

Lösung:

Man muss in startup.cs den Connection Eintrag zur Datenbank hinzufügen

using Microsoft.EntityFrameworkCore;

using test04.Models;

..

..

public void ConfigureServices(IServiceCollection services)

        {

            var connection = @"Server=(localdb)\mssqllocaldb;Database=Test04;Trusted_Connection=True;";

            services.AddDbContext<app_DbContext>(options => options.UseSqlServer(connection));

 

            services.AddMvc();

        }

 

 

 

Eingabe in der  Package Manager Concolse

PM> add-migration initial

Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]

      User profile is available. Using 'C:\Users\Raimund\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.

Unable to create an object of type 'app_DbContext2'. Add an implementation of 'IDesignTimeDbContextFactory<app_DbContext2>' to the project, or see https://go.microsoft.com/fwlink/?linkid=851728 for additional patterns supported at design time.

 

 

Mobile

.

123movies