Note that there are some explanatory texts on larger screens.

plurals
  1. POEF Code First Database Not Generated using MVC3
    primarykey
    data
    text
    <p>I'm developing an app using EF Code First and MVC3. The solution contains three pprojects; <strong>ProjectName.Model</strong> involving <strong>POCO</strong> classes only, <strong>ProjectName.App</strong> involving <strong>MVC3</strong> web project from that the default Model folder (created by MVC itself) is removed from, and <strong>ProjectName.Repository</strong> that is containing a <strong>generic repository, UnitOfWork, plus DatabaseContext classes</strong>. The <strong>problem</strong> is that, the EF5 generates the Database but with no tables included:</p> <pre><code>public class DatabaseContext : DbContext { public DatabaseContext() : base("name=MahalehMaDB") { } // public DbSet&lt;Man&gt; Mans { get; set; } public DbSet&lt;City&gt; Cities { get; set; } public DbSet&lt;Role&gt; Roles { get; set; } public DbSet&lt;RoleGroup&gt; RoleGroups { get; set; } public DbSet&lt;Service&gt; Services { get; set; } public DbSet&lt;ServiceRole&gt; ServiceRoles { get; set; } public DbSet&lt;ServiceDetails&gt; ServiceDetails { get; set; } public DbSet&lt;ActionProvider&gt; ActionProviders { get; set; } public DbSet&lt;RoleGroupUser&gt; RoleGroupUsers { get; set; } // public static void InitializeDatabase() { using (DatabaseContext context = new DatabaseContext()) { context.Database.CreateIfNotExists(); Database.SetInitializer(new MigrateDatabaseToLatestVersion&lt;DatabaseContext, Configuration&gt;()); } } } &lt;connectionStrings&gt; &lt;add name="MahalehMaDB" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=MahalehDatabase;Integrated Security=True;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" /&gt; </code></pre> <p></p> <p>And I'm confused what might be preventing the EF5 from generating the Database with its tables. Note that, the <strong>InitializeDatabase</strong> method is called in the Application_Start method of Global.asax file. Is there something wrong with the InitializeDatabase method? Controller classes are also implemented incomplete, Could it be the caues? I've been surfing the web so much but couldn't handle it, thus decided to come here!</p> <p>Does anyone have any idea to handle the problem? Please let me know if the information isn't enough.</p> <p>Kindly appreciate...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload