Polecenie update-database w Entity Framework

Polecenie update-database w Entity Framework
MK
  • Rejestracja:około 3 lata
  • Ostatnio:23 dni
  • Postów:84
0

Podczas polecenia update-database pojawia się następujący błąd:

Kopiuj
A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - Łańcuch certyfikatów został wystawiony przez urząd, którego nie jest zaufany.)

Będę wdzięczny za pomoc w rozwiązaniu tego problemu. Oto kod:

Kopiuj
using Microsoft.EntityFrameworkCore;

namespace RestaurantAPI.Entities
{
    public class RestaurantDbContext : DbContext
    {
        private string _connectionString = "Server=KAMIL;Database=RestaurantDb;Trusted_Connection=True;Encrypt=True;TrustServerCertificate=False;";
        public DbSet<Restaurant> Restaurants { get; set; }
        public DbSet<Address> Addresses { get; set; }
        public DbSet<Dish> Dishes { get; set; }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Restaurant>()
                .Property(r => r.Name)
                .IsRequired()
                .HasMaxLength(25);

            modelBuilder.Entity<Dish>()
                .Property(d => d.Name)
                .IsRequired();
        }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseSqlServer(_connectionString);
        }
    }
}
Ferdynand Lipski
  • Rejestracja:ponad 5 lat
  • Ostatnio:około 2 miesiące
  • Postów:77
4

Zmień końcówkę wartości _connectionString na TrustServerCertificate=True.

MK
  • Rejestracja:około 3 lata
  • Ostatnio:23 dni
  • Postów:84
0

Teraz działa. Wielkie dzięki.

Zarejestruj się i dołącz do największej społeczności programistów w Polsce.

Otrzymaj wsparcie, dziel się wiedzą i rozwijaj swoje umiejętności z najlepszymi.