I receive error
{"Invalid column name 'Role_Id'.\r\nInvalid column name 'User_Id'."}
when I try to get all permissions like this:
public IEnumerable<Permission> GetAllPermissions()
{
return base.DataContext.Permissions;
}
What are these "Role_id" and "User_id"??? They don't exist neither in my model nor in database... What does it mean? In my entire solutions I don't have anything like "Role_id" and "User_id"
This is query from DataContext (what are those "Role_id" and "User_id"...?):
{SELECT
[Extent1].[Id] AS [Id],
[Extent1].[Name] AS [Name],
[Extent1].[Role_Id] AS [Role_Id],
[Extent1].[User_Id] AS [User_Id]
FROM [dbo].[Permissions] AS [Extent1]}
Permission model looks like :
public class Permission : INotifyPropertyChanged
{
private string name;
public int Id
{
get;
set;
}
public string Name
{
get
{
return this.name;
}
set
{
this.name = value;
this.OnPropertyChanged("Name");
}
}
public Permission()
{
}
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler propertyChangedEventHandler = this.PropertyChanged;
if (propertyChangedEventHandler != null)
{
propertyChangedEventHandler(this, new PropertyChangedEventArgs(propertyName));
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
Table in database:
Context:
public class MyContext : DbContext
{
public DbSet<User> Users { get; set;}
public DbSet<Role> Roles { get; set;}
public DbSet<RolePermission> RolePermissions { get; set;}
public DbSet<Permission> Permissions { get; set;}
...
public MyContext()
: base("name=my_Connection")
{
System.Data.Entity.Database.SetInitializer<MyContext>(new CreateDatabaseIfNotExists<MyContext>());
}
}