static void Main(string[] args) { TestContext context = new TestContext(connString); goods_type myType = new goods_type(); myType.type_code = "T001"; myType.type_name = "测试类型1"; context.AddTogoods_type(myType); goods myGoods = new goods(); myGoods.goodsid = "G001"; myGoods.name = "测试货物1"; myGoods.goods_type = myType; context.AddTogoods(myGoods); store myStore = new store(); myStore.store_code = "S001"; myStore.store_name = "测试仓库1"; context.AddTostore(myStore); onhand myOnhand = new onhand(); myOnhand.goods = myGoods; myOnhand.store = myStore; myOnhand.onhand1 = 100; context.AddToonhand(myOnhand); context.SaveChanges(); }