#

 

C# EntityTypeBuilder does not contain a definition for ToTable and no accessible extension method ToTable

 

 

Bei verwenden von Entity Framework in einer Windows Application

CS1061

'EntityTypeBuilder<ArticleDbModel>' does not contain a definition for 'ToTable' and no accessible extension method 'ToTable' accepting a first argument of type 'EntityTypeBuilder<ArticleDbModel>' could be found (are you missing a using directive or an assembly reference?)

 

Ein Bild, das Text enthält.
Automatisch generierte Beschreibung

 

Lösung:

Man muss unter nuget packages das packet:
Microsoft.EntityFrameworkCore.Relational hinzufügen

Ein Bild, das Text, Monitor, Screenshot, schwarz enthält.
Automatisch generierte Beschreibung

 

using DataModels;

using Microsoft.EntityFrameworkCore;

 

namespace webapp_codedocu.Data

{

    public class ApplicationDbContext : DbContext

    {

        public ApplicationDbContext(DbContextOptions options) : base(options) { }

 

 

        #region  Datasets

        //--< Datasets in this Project >--

        public virtual DbSet<ArticleDbModel> tbl_Articles { get; set; }

        //--</ Datasets in this Project >---

        #endregion /Datasets

 

 

        protected override void OnModelCreating(ModelBuilder modelBuilder)

        {

            base.OnModelCreating(modelBuilder);

            //------------< region: Datase-Tables to Models >------------

            //*zuweisen der Model-Klasse zur Sql-Server Tabelle

 

            modelBuilder.Entity<ArticleDbModel>().ToTable("tbl_Articles");

 

            //------------</ region : Datase-Tables to Models >------------

        }

    }

}

 

 

 

 

 

 

 

//protected override void OnModelCreating(ModelBuilder builder)

//{

//    base.OnModelCreating(builder);

 

//}

 

Mobile

.

123movies