EntityFramework SET ROLE How to
Posted: Fri 28 Aug 2009 08:53
Hi experts,
i want to use
SET ROLL APP_ROLE;
during Connection_StateChange event.
I tryed:
private void Connection_StateChange(object sender, System.Data.StateChangeEventArgs e)
{
if (e.CurrentState == System.Data.ConnectionState.Open)
{
DbConnection conn = sender as DbConnection;
int result = 0;
using (DbCommand command = conn.CreateCommand())
{
command.CommandText = "SET ROLE APP_ADMIN";
result = command.ExecuteNonQuery();
}
}
But I get an EntitySqlException Sql Statement error near ID ROLE
Is it not possible to do this for a connection or missed i something??.
Question is, how to set a role as the first action after the connection opens?
Thanks
Roman
i want to use
SET ROLL APP_ROLE;
during Connection_StateChange event.
I tryed:
private void Connection_StateChange(object sender, System.Data.StateChangeEventArgs e)
{
if (e.CurrentState == System.Data.ConnectionState.Open)
{
DbConnection conn = sender as DbConnection;
int result = 0;
using (DbCommand command = conn.CreateCommand())
{
command.CommandText = "SET ROLE APP_ADMIN";
result = command.ExecuteNonQuery();
}
}
But I get an EntitySqlException Sql Statement error near ID ROLE
Is it not possible to do this for a connection or missed i something??.
Question is, how to set a role as the first action after the connection opens?
Thanks
Roman