我在更改我的实体连接字符串时遇到了这个问题。
这是代码:
SqlConnectionStringBuilder sqlBuilder = new SqlConnectionStringBuilder();
sqlBuilder.DataSource = @"KURT-PC\SQLEXPRESS";
sqlBuilder.InitialCatalog = "KurtDB";
sqlBuilder.UserID = "Admin";
sqlBuilder.Password = "123456";
sqlBuilder.IntegratedSecurity = false;
sqlBuilder.MultipleActiveResultSets = true;
EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder();
entityBuilder.Provider = "System.Data.SqlClient";
entityBuilder.ProviderConnectionString = sqlBuilder.ToString();
entityBuilder.Metadata = @"res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl";
this.Entities.Connection.ConnectionString = conn.Connection.ConnectionString = entityBuilder.ConnectionString.ToString();
当它尝试更改连接字符串时,它给了我一个 InvalidOperationEsception。
错误详细信息:通过打开连接或使用 MetadataWorkspace 构建连接来注册元数据后,不允许对连接进行修改。
任何帮助它让我无言以对....