我已经创建了我的连接字符串,它似乎连接没有错误。我只是想输出各种ID
s,但它的表现就像那里什么都没有!
该表充满了记录......它也没有输出任何错误。我怎么能调试这样的东西?
模型:
namespace MvcApplication1.Models
{
public class Directory
{
public int ID { get; set; }
public bool DELETED { get; set; }
public Guid CREATED_BY { get; set; }
public DateTime DATE_ENTERED { get; set; }
public Guid MODIFIED_USER_ID { get; set; }
public DateTime DATE_MODIFIED { get; set; }
public Guid USER_ID { get; set; }
public Guid BRANCH_ID { get; set; }
}
public class MyDbContext : DbContext
{
public DbSet<Directory> Directories { get; set; }
}
}
看法:
@model IEnumerable<MvcApplication1.Models.Directory>
@foreach (var item in Model) {
<tr>
<td>
@item.ID
</td>
</tr>
}
控制器:
namespace MvcApplication1.Controllers
{
public class HomeController : Controller
{
private Models.MyDbContext db = new Models.MyDbContext();
public ActionResult Index()
{
ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
return View(db.Directories.ToList());
}
}
}