Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

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

20.02.2023 (👁4821)

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

 

//}