In EF, I tried adding a record using syntax:
Context.Set<TABLENAME>().Add(TABLEROW)
I get this crazy error: "An item cannot be removed from a fixed size Array of type"
I did a bit of goggling and it suggests I change from DBSet to List from the generated context file of:
public partial class GeniusDBContext : DbContext
{
public virtual DbSet<TABLENAME> TABLENAMES { get; set; }
...
}
to
public partial class GeniusDBContext : DbContext
{
public virtual List<TABLENAME> TABLENAMES { get; set; }
...
}
This is ridiculous because if you change the .edmx file, you will lose these changes. Is there another way around this?
DbSet<>
is correct, there is no need to change it to List<>
. I think the suggestion found has been be misleading and was not the problem.
To add a new entity, try this:
var ctx = new GeniusDBContext();
var entity = new MyEntity();
ctx.MyEntities.Add(entity);