Why mapping is not working using Entity Framework in visual studio 2015 professional

asp.net-mvc c# entity-framework-6 visual-studio-2015

Question

I have created a context of Entity Framework like below: using System;

 using System.Data.Entity;
 using System.Data.Entity.ModelConfiguration.Conventions;
 using System.Collections.Generic;
 using System.Linq;
 using System.Web;

 namespace UniversityApp.Models
 {
   public class ProfDb : DbContext
      {

        public DbSet<Professor> Professors { get; set; }
         public DbSet<Student> Students { get; set; }

         }
     }

I am using VS 2015 Professional. Then I go to View=>Server Explorer=> Add Connection=> Microsoft Sql Server => In Data Source I choose (LocalDb)\MSSQLLocalDB , and when I go to select a database name I do not find UniversityApp.Models.ProfDb as an option. I have also created a new object of ProfDb in one of my controller but still not working. Should anyone tell me why mapping is not working in my application and what I should do?

1
1
1/8/2017 1:30:43 PM

Popular Answer

Try this, Go to Web config, search for

 <entity framework>

Add this

<contexts>
 <context type="UniversityApp.Models.ProfDb , UniversityApp">
  <databaseInitializer type="Your SEED , UniversityApp" />
</context>

0
1/8/2017 2:44:12 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow