You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In attempting to seed the EFFORT database, it would be nice to use C#'s SqlClient namespace. However, after creating an Effort.Provider.EffortConnection, the casting of this to System.Data.SqlClient.SqlConnection fails so it's not possible to make subsequent calls to SqlCommand or ExecuteNonQuery(). See code sample below.
Any ideas on how to get this cast to work?
public static void Load_Data_Into_Effort(Effort.Provider.EffortConnection effortConnection) { string sql = seedData(); // returns sql script file contents System.Data.SqlClient.SqlConnection cnn = (SqlConnection)effortConnection; try { //cnn.Open(); // not sure if this call is necessary, since Effort Db is already open SqlCommand cmd = new SqlCommand(sql, cnn); cmd.ExecuteNonQuery(); cmd.Dispose(); cnn.Close(); } catch (Exception ex) { Debug.WriteLine($"Error: {ex}"); } }
The text was updated successfully, but these errors were encountered:
I reviewed the discussion in issue #54 where you remark, " It only supports the database independent entity SQL statements," and provides a link to Microsoft's "Entity SQL" blog. From there I tried to get this code to work, but it also fails with a casting exception, since apparently the call to ObjectContext is a Core feature and EntityConnection requires its metadata to be .NET.
This may not solve it, but is there a way to convert MetadataWorkspace from Core back to .NET?
var metadata = ((IObjectContextAdapter)effortContext).ObjectContext.MetadataWorkspace; var _connection = new EntityConnection(metadata, effortConnection);
In attempting to seed the EFFORT database, it would be nice to use C#'s SqlClient namespace. However, after creating an Effort.Provider.EffortConnection, the casting of this to System.Data.SqlClient.SqlConnection fails so it's not possible to make subsequent calls to SqlCommand or ExecuteNonQuery(). See code sample below.
Any ideas on how to get this cast to work?
public static void Load_Data_Into_Effort(Effort.Provider.EffortConnection effortConnection) { string sql = seedData(); // returns sql script file contents System.Data.SqlClient.SqlConnection cnn = (SqlConnection)effortConnection; try { //cnn.Open(); // not sure if this call is necessary, since Effort Db is already open SqlCommand cmd = new SqlCommand(sql, cnn); cmd.ExecuteNonQuery(); cmd.Dispose(); cnn.Close(); } catch (Exception ex) { Debug.WriteLine($"Error: {ex}"); } }
The text was updated successfully, but these errors were encountered: