我正在学习 ADO.Net 实体框架,并且一直在将实体表对象添加到数据库中。
我在解决方案中有一个名为 testDB 的本地数据库。它有两列 - id(primary, unique, identiy),name(varchar(100)) 和它的实体。主要应用程序代码如下。问题是,使用此代码不会向表中添加任何内容,但我也没有任何错误。会出什么问题?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace entityproject
{
class Program
{
static void Main(string[] args)
{
String someString;
someString = "Just a test";
testDBEntities tdbEntity = new testDBEntities();
test tblTest = new test();
tblTest.name = someString;
tdbEntity.test.Add(tblTest);
tdbEntity.SaveChanges();
}
}
}
App.config 在这里 http://pastie.org/6980938