[英]Why mapping is not working using Entity Framework in visual studio 2015 professional
我已经创建了如下所示的Entity Framework上下文: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; }
}
}
我正在使用VS 2015 Professional。 然后我去查看=>服务器资源管理器=>添加连接=> Microsoft Sql Server =>在数据源中,我选择(LocalDb)\\ MSSQLLocalDB,当我选择一个数据库名称时,我没有找到UniversityApp.Models.ProfDb作为一个选项。 我还在其中一个控制器中创建了ProfDb的新对象,但仍然无法正常工作。 谁能告诉我为什么映射在我的应用程序中不起作用以及我应该怎么做?
试试这个,转到Web配置,搜索
<entity framework>
加上这个
<contexts>
<context type="UniversityApp.Models.ProfDb , UniversityApp">
<databaseInitializer type="Your SEED , UniversityApp" />
</context>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.