public void SetToDatabase(string username, string text) { using (chatting_rpcEntities1 chattingData = new chatting_rpcEntities1()) { try { chat newChat = new chat(); newChat.username = username; newChat.text = text; chattingData.chats.Add(newChat); chattingData.SaveChanges(); } catch (Exception error) { Console.WriteLine(error.Message); } } }