开发者

I can read from SQL server database but can not save

I am using Entity Framework. I can read the data from SQL server 2008 but can not save the data. Here is my connection string. I manually ran the Insert statement on the database. It works. But I can't insert from the code.

<add name="TestEntities" connectionString="metadata=res://*/Models.TestDB.csdl|res://*/Models.TestDB.ssdl|res://*/Models.TestDB.msl;provider=System.Data.SqlClient;prov开发者_开发问答ider connection string=&quot;Data Source=TESTDEV;Initial Catalog=AttachDbFilenameC:\test\TestDB.mdf;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />



       using (TestEntities db1 = new TestEntities())
        {

            Order O = new Order();
            O.OrderTypeID = 1;
            O.UserID = 29210;
            db1.AddToOrderss(O);
            db1.SaveChanges();
        }


I deleted the existing model and created a new database and new model. It's working fine. Thanks for the hint James.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜