Mad*_*Boy 6 c# entity-framework
我决定把Entity Connection String从app.config代码.但是在设置之后如下:
    public static string GetConnectionString() {
        string connection = "";
        SqlConnectionStringBuilder sqlBuilder = new SqlConnectionStringBuilder();
        sqlBuilder.DataSource = dbServer;
        sqlBuilder.InitialCatalog = dbInitialCatalog;
        sqlBuilder.IntegratedSecurity = false;
        sqlBuilder.UserID = dbUserName;
        sqlBuilder.Password = dbPasswWord;
        sqlBuilder.MultipleActiveResultSets = true;
        EntityConnectionStringBuilder entity = new EntityConnectionStringBuilder();
       // entity.Name = "EntityBazaCRM";
        entity.Metadata = @"res://*/Data.System.csdl|res://*/Data.System.ssdl|res://*/Data.System.msl";
        entity.Provider = "System.Data.SqlClient";
        entity.ProviderConnectionString = sqlBuilder.ToString();
        connection = entity.ToString();
        return connection;
    }
我Unable to load the specified metadata resource.在.Designer.cs中抛出异常.
    /// <summary>
    /// Initialize a new EntityBazaCRM object.
    /// </summary>
    public EntityBazaCRM(string connectionString) : base(connectionString, "EntityBazaCRM")
    {
        this.ContextOptions.LazyLoadingEnabled = true;
        OnContextCreated();
    }
如果我在我的Entity创建者中定义.Name,则会抛出另一个异常
"Other keywords are not allowed when the 'Name' keyword is specified." (System.ArgumentException)  Exception Message = "Other keywords are not allowed when the 'Name' keyword is specified.", Exception Type = "System.ArgumentException"
我知道我错过了一些我必须改变的东西,以便自生成的代码使用新的连接字符串,但在哪里寻找它?
Mad*_*Boy 27
  entity.Metadata = @"res://*/Data.System.csdl|res://*/Data.System.ssdl|res://*/Data.System.msl";
至:
  entity.Metadata = "res://*/";
它的工作原理:-)
| 归档时间: | 
 | 
| 查看次数: | 20415 次 | 
| 最近记录: |