public MvcBlogEntities MvcBlog = new MvcBlogEntities();
User user = new User();
                user.Name = collection["Name"];
                user.Password = collection["Password"];
                user.Email = collection["Email"];
                user.RegDate = System.DateTime.Now;
                user.Level = 0;
                user.Score = 0;                MvcBlog.AddToUser(user);
但是以上代码放进VS中后一直报错
AddToUser方法未定义。但是我的数据库是有这么一个表的。且代码只有最后一行报错。
跪求各位大神帮忙!!!!!

解决方案 »

  1.   

    dbContext.[你的User表名].InsertObject(MvcBlog);
    dbContext.SaveChanges();
      

  2.   

    dbContext.[你的User表名].InsertObject(User);
    dbContext.SaveChanges();
      

  3.   

    可是InsertObject()这个方法同样找不到定义啊~
      

  4.   

    是否是缺少引用的问题
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;using MvcBlog.Models;还有我用的是VS2012
      

  5.   

    重新产生下 edmx 文件。
      

  6.   

    谢谢,问题已解决~是VS2012中将AddTo方法重写了
    最后一行应该改成MvcBlog.User.Add(user)
    就可以了。