mvc新学者,求教一下遇到的问题?
我新学MVC下了个教程按照教程上面做,链接数据库时出现错误!我的实体类
using System;
using System.Linq;
using System.Data.Entity;
namespace MvcMovie.Models
{
public class ecsbusinessinfo
{
public int ID { get; set; }
public int infotype { get; set; }
public string infotypename { get; set; }
public string infocategoryid { get; set; }
public DateTime addtime { get; set; }
public string infocategoryname { get; set; }
}
public class DBContext : DbContext
{
public DbSet<ecsbusinessinfo> ecsbusinessinfos { get; set; }
}
}
数据处理的类
using MvcMovie.Models;
using System.Linq;
using System;
using System.Web.Mvc;
namespace MvcMovie.Controllers
{
public class MoviesController : Controller
{
//
// GET: /Movies/
DBContext db = new DBContext();
public ActionResult Index()
{
var binfos = from m in db.ecsbusinessinfos
where m.addtime > new DateTime(2011, 6, 1)
select m;
return View(binfos.ToList());
}
}
}
前台绑定完成之后运行
提示:对象名'dbo.ecsbusinessinfoes无效。
我数据库表为“ecsbusinessinfo”,程序上没有设置表名。为什么生成出来的表名多了一个es呢?
求大侠告诉我? --------------------编程问答-------------------- db.ecsbusinessinfos
=》
db.ecsbusinessinfo 试试
--------------------编程问答-------------------- 代码没看出错误。如果你没有库的话 EF会自动生成库。你看看你的数据库连接的库和你的库一致不 --------------------编程问答-------------------- 我调试获取到的到的binfos的sql语句有问题!
产生的sql语句的表名变成了[dbo].[ecsbusinessinfoes]
哪位告诉我下该怎么会出现这种问题
SELECT
[Extent1].[ID] AS [ID],
[Extent1].[infotype] AS [infotype],
[Extent1].[infotypename] AS [infotypename],
[Extent1].[infocategoryid] AS [infocategoryid],
[Extent1].[addtime] AS [addtime],
[Extent1].[infocategoryname] AS [infocategoryname]
FROM [dbo].[ecsbusinessinfoes] AS [Extent1]
WHERE [Extent1].[addtime] > convert(datetime, '2011-06-01 00:00:00.000', 121)
补充:.NET技术 , ASP.NET