我试图在运行时在我的实体框架中设置我的连接字符串。为了做到这一点,我有以下代码:
string connectionString = "tcp:[serverName],[port];initial catalog=[databaseName];user id=[userName];password=[pwd];MultipleActiveResultSets=True;App=EntityFramework";
using (MyEntities entities = new MyEntities(connectionString))
{
MyEntity entity = new MyEntity();
// Set entity properties here
entities.MyEntities.Add(entity);
entities.SaveChanges();
}
当我到达说 的那一行时,entities.MyEntities.Add(entity)
会引发异常。该异常具有以下信息:
Type: ArgumentException
Message: Keyword not supported: 'tcp:[serverName],[port];initial catalog'.
为什么我写的代码不起作用?对于我的生活,我无法弄清楚。
谢谢!