【发布时间】:2013-04-25 13:25:38
【问题描述】:
我已经开始在 ASP.NET MVC4 中使用实体框架了。
我在Model 文件夹中创建了 3 个类,并为每个模型创建了控制器。
现在,当我运行应用程序时,它已经创建了与每个模型类对应的单独数据库。
有什么方法可以让我们只使用一个数据库?
【问题讨论】:
-
你的上下文是如何定义的?
-
请发布您的上下文类。
-
我的上下文类就像-'public class EmployeeDbContext : DbContext { public DbSet
Employees { get;放; } }' -
我的上下文类是这样的- 1. 这是我的模型类
public class Employee { [Key] public int EmpId { get; set; } [Required] public string FullName { get; set; } [Required] public string DateOfBirth { get; set; } [Required] public string Designation { get; set; } [Required] public string Email { get; set; } [Required] public string Gender { get; set; } [Required] public string ContactNo { get; set; } [Required] public string Role { get; set; } } -
这是我的上下文类
标签: c# asp.net sql-server asp.net-mvc-4 entity-framework-5