Scaffolding no longer works, too

Nov 11, 2011 at 6:35 AM

I, i use the current version 1.0.6 of MVCScaffolding with Visual Studio 2010 and the EF.

And now i get this error:

####

Scaffolding DatenfeldController...
Invoke-Scaffolder : B2BPlattform.Models.b2bplattformDbContext is not a System.Data.Entity.DbContext class and does not
contain a 'Datenfeld' property, so it cannot be used as the database context.
Bei C:\Projekte\b2bplattform\source\packages\MvcScaffolding.1.0.6\tools\Controller\MvcScaffolding.Controller.ps1:66 Zei
chen:40
+         $dbContextScaffolderResult = Scaffold <<<<  DbContext -ModelType $foundModelType.FullName -DbContextType $DbC
ontextType -Area $Area -Project $Project -CodeLanguage $CodeLanguage -BlockUi
    + CategoryInfo          : NotSpecified: (:) [Invoke-Scaffolder], RuntimeException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.InvokeScaffolderCmdlet

####

At the project start the scaffolding works.

But now i change some modelnames and the enities and it does not work for creating new controllers.

When i use the default scaffolding from visual studio the scaffolding to create controllers udn views works fine.

But i will use the great MVCScaffolding to create my controllers and views.

Has anyone some hints for me?

Nov 11, 2011 at 7:05 AM

Here is the begining of my b2bdbcontext class:

 

    public partial class b2bplattformDbContext : ObjectContext
    {
        #region Konstruktoren
   
        /// <summary>
        /// Initialisiert ein neues b2bplattformDbContext-Objekt mithilfe der in Abschnitt 'b2bplattformDbContext' der Anwendungskonfigurationsdatei gefundenen Verbindungszeichenfolge.
        /// </summary>
        public b2bplattformDbContext() : base("name=b2bplattformDbContext", "b2bplattformDbContext")
        {
            this.ContextOptions.LazyLoadingEnabled = true;
            OnContextCreated();
        }
   
        /// <summary>
        /// Initialisiert ein neues b2bplattformDbContext-Objekt.
        /// </summary>
        public b2bplattformDbContext(string connectionString) : base(connectionString, "b2bplattformDbContext")
        {
            this.ContextOptions.LazyLoadingEnabled = true;
            OnContextCreated();
        }
   
        /// <summary>
        /// Initialisiert ein neues b2bplattformDbContext-Objekt.
        /// </summary>
        public b2bplattformDbContext(EntityConnection connection) : base(connection, "b2bplattformDbContext")
        {
            this.ContextOptions.LazyLoadingEnabled = true;
            OnContextCreated();
        }

Nov 21, 2011 at 10:19 AM
The error comes from you b2bplattformDbContext that is not a DBContext class - it is an ObjectContext. DbContext supports CodeFirst and it's used in the T4Scaffolding templates.
hendriklenz wrote:

Here is the begining of my b2bdbcontext class:

 

    public partial class b2bplattformDbContext : ObjectContext
    {

Nov 21, 2011 at 11:53 AM

Hi,

and is there a way to change this now and use my current code?

I create the model from a mysql database.

Thanks

Hendrik

Nov 21, 2011 at 1:49 PM

I have not tried generation of DbContext from database but http://msdn.microsoft.com/en-us/library/gg696166%28v=vs.103%29.aspx describes exactly what you want. Hope this helps.