当我登录我的简单应用程序时。它会出现此错误。
概念方类型“Converter.Session”中成员'SessionId'的类型'Edm.Int32'与对象方成员'SessionId'的类型'System.Decimal'不匹配输入
在我的错误行代码
下面List<User> users = context.Users.ToList<User>();
吹完我的完整代码
private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
InputBox("User Name", "Please enter User ID", ref UserName);
QuestionId = 0;
Boolean UserExsits = false;
context = new ConversionGameDBContainer();
List<User> users = context.Users.ToList<User>();// this is error line
foreach (User i in users)
{
if (i.UserId.ToString().Trim().Equals(UserName.Trim()))
{
UserExsits = true;
UserLogged = true;
MessageBox.Show("Hello " + UserName + "!!! you are back, Enjoy the game");
break;
}
}
if (!UserExsits)
{
User u = new User();
u.UserId = UserName;
context.Users.Add(u);
context.SaveChanges();
MessageBox.Show("User Id " + UserName + " Created and enjoy the game");
UserLogged = true;
}
ConvertorButton.Enabled = false;
if (UserLogged)
{
DateTime d = DateTime.Now;
session = new Session();
session.StartTime = d;
session.UserId = UserName;
context.Sessions.Add(session);
context.SaveChanges();
context.Entry(session).GetDatabaseValues();
SessionId = session.SessionId;
}
if (f == null)
{
f = new HistoryResult();
}
PlayConversionGame.UserName = UserName;
f.Show();
String Output = "";
context = new ConversionGameDBContainer();
}
答案 0 :(得分:0)
我知道这个问题有点陈旧,但在遇到同样的错误信息时我偶然发现了它。
删除bin和object文件夹,然后重新运行项目,为我解决了问题。
另见这个问题(编辑OP的一部分): How to solve the following MappingException