C# Visual Studio C,错误2016,错误2016:为条件指定的值与成员的类型不兼容

C# Visual Studio C,错误2016,错误2016:为条件指定的值与成员的类型不兼容,c#,mysql,database,module,C#,Mysql,Database,Module,我一直在用关系数据库开发应用程序。我正在学习在线教程 大约凌晨3点25分,这家伙在他的VisualStudio2010中使用了AddTos函数,我在VS2012中找不到确切的函数。然而,我发现了一些等价的东西,比如database.s.Additem,它报告了令人困惑的错误。。。。。谁能告诉我这是什么错误以及我如何解决它 详情如下: 这个项目所做的就是通过单击按钮来使用一个按钮,一个项目将被添加到数据库下的表中 像往常一样,我创建了一个包含四个表的数据库: TblProductType TblP

我一直在用关系数据库开发应用程序。我正在学习在线教程

大约凌晨3点25分,这家伙在他的VisualStudio2010中使用了AddTos函数,我在VS2012中找不到确切的函数。然而,我发现了一些等价的东西,比如database.s.Additem,它报告了令人困惑的错误。。。。。谁能告诉我这是什么错误以及我如何解决它

详情如下:

这个项目所做的就是通过单击按钮来使用一个按钮,一个项目将被添加到数据库下的表中

像往常一样,我创建了一个包含四个表的数据库:

TblProductType
TblProduct
TblTransaction
TblTransactionItem
在服务器资源管理器->数据连接下,这些表在名为:CoffeeShopDatabase的数据库下定义

下面是我的代码,用于定义在我的应用程序上单击按钮 显然,由于这四个表是通过1到多个键关联的,CoffeeShopDatabaseEntities2成为了类型,其中包括与这四个表相关的变量类型/函数,例如TblProducts等

以下代码试图用记录更新表TblProduct

{Large Coffee, 1.99M}. 
首先,我定义了一个CoffeeShopDatabaseEntities2类型的变量,称为csde;然后我设置了一个TblProduct变量product1作为要添加的记录;然后我将product1添加到

csde(a database)>TblProducts() 
我正在使用VisualStudio2012,并且正在尝试使用VS2010进行在线教程。显然,在教程中,这个家伙用了

csde.AddToTblProducts(product1);  ---------VS 2010
然而,我无法在2012年的VS中找到相同的结果,但我最终找到了

csde.TblProducts.Add(product1);  ----------VS 2012
并将其用作替换,从CSD数据库将记录product1添加到TBLPProduct表中

以下是我得到的错误:

Error   2   Error 2016: The value specified for the condition is not
compatible with the type of the member. C:\Users\Support\Documents\Visual Studio
2012\Projects\CoffeeShopProject\CoffeeShopProject\
testCoffeeShopDatabase.edmx 157 17  CoffeeShopProject
同时,当代码运行时,窗口弹出,我点击按钮,过了一会儿,一个白色的小窗口弹出说:

Schema specified is not valid. Errors: 

testCoffeeShopDatabase.msl(8,12) : error 2016: 
The value specified for the condition is not compatible 
with the type of the member.
,指向:

csde.TblProducts.Add(product1); 
我是C语言的新手,当我看到这个邪恶的白色窗口时,我总是觉得无能为力。。。。如有任何帮助或建议,将不胜感激

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CoffeeShopProject
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            CoffeeShopDatabaseEntities2 csde = new CoffeeShopDatabaseEntities2();
            TblProduct product1 = new TblProduct()
            {
                Description = "Large Coffee",
                Price = 1.99M
            };
            csde.TblProducts.Add(product1);
            csde.SaveChanges();
        }
    }
}