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方法未定义。但是我的数据库是有这么一个表的。且代码只有最后一行报错。
跪求各位大神帮忙!!!!!
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方法未定义。但是我的数据库是有这么一个表的。且代码只有最后一行报错。
跪求各位大神帮忙!!!!!
dbContext.SaveChanges();
dbContext.SaveChanges();
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;using MvcBlog.Models;还有我用的是VS2012
最后一行应该改成MvcBlog.User.Add(user)
就可以了。