codedocu.de

 

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?)

 

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

 

Lösung:

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

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

 

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);

 

//}

 


Software Entwicklung Stuttgart Nürtingen
Suche Projekte C#, WPF, Windows App,ASP.Net, vb.Net, WinForms, SQL Server, Access, Excel