Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

There was an error running the selected generator . try rebuilding the project

When I create the Scaffold and add the Model class then I am getting these error "There was an error running the selected generator . try rebuilding the project"

I have three Model class :

1.Department.CS

2.Designation.cs

3.CompanyDBContext.cs

Database : I have two table in database, 1. Department(deptID,deptName,Description) 2. Designation(desgtID,desgName,description)

Objective :- I want to create one view page for these scenario. Like this

Insert Name of Form (TextBox) + Department Name (Dropdown list box) + Designation Name (Dropdown list box)

1.Department.CS

namespace mvcAppraisalSystem.Models
{
  public class Department
  {
    [Key]
    public int deptID { get; set; }
    public string deptName { get; set; }
    public string Description { get; set; }
  }
 }

2.Designation.cs

namespace mvcAppraisalSystem.Models
{
   public class Designation
   {
      [Key]
      public int desgID { get; set; }
      public string desgName { get; set; }
      public string description { get; set; }
   }
 }

3.CompanyDBContext.cs

 namespace mvcAppraisalSystem.Models
 {
   public class CompanyDBContext : DbContext
   {
      public DbSet<CompanyDBContext> Departments { get; set; }

      public DbSet<CompanyDBContext> Designations { get; set; }
   }
 }
like image 640
Anurag Jain Avatar asked Dec 30 '13 14:12

Anurag Jain


1 Answers

This is the problem with the connection string you can change the connection string with your DbContext name like bellow on the file web.config:

<connectionStrings>
  <add name="MovieDBContext" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-MVCmove-20140616082808.mdf;Initial Catalog=aspnet-MVCmove-20140616082808;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>

For the class:

using System;
using System.Data.Entity;
namespace MVCmove.Models
{
  public class Movie
  {
    public int ID { get; set; }
    public string Title { get; set; }
    public DateTime ReleaseDate { get; set; }
    public string Default1Genre { get; set; }
    public decimal Price { get; set; }
  }
  public class MovieDBContext : DbContext
  {    
    public DbSet<Movie> Movies { get; set; }
  }
}
like image 99
Nasel P Nazeer Avatar answered Sep 24 '22 00:09

Nasel P Nazeer