Hi.
I am trying to integrate this example in my work. But I run into a problem with my entities.
I get this when accessing my repository on an entity:
> System.InvalidOperationException: The entity type Estate is not part of the model for the current context.
In the Repository.cs:
```
public virtual void Insert(TEntity entity)
{
((IObjectState)entity).ObjectState = ObjectState.Added;
_dbSet.Attach(entity); // <-- The error occurs here
_context.SyncObjectState(entity);
}
```
This is my DbContext:
```
public partial class DimensionWebDbContext : DbContextBase
{
public DimensionWebDbContext() :
base("DimensionWebContext")
{
Database.SetInitializer<DimensionWebDbContext>(new CreateDatabaseIfNotExists<DimensionWebDbContext>());
Configuration.ProxyCreationEnabled = false;
}
public new IDbSet<T> Set<T>() where T : class
{
return base.Set<T>();
}
}
```
And the Entity:
```
public class Estate : EntityBase
{
public int Id { get; set; }
public string Name { get; set; }
public string Subject { get; set; }
public DateTime DateAdded { get; set; }
public Status Status { get; set; }
public decimal GrossArea { get; set; }
public decimal NetArea { get; set; }
public decimal CommenArea { get; set; }
public int Year { get; set; }
public int Rooms { get; set; }
public bool Balcony { get; set; }
public decimal Price { get; set; }
public decimal Payment { get; set; }
public virtual EstateAddress Address { get; set; }
public virtual EstateType Type { get; set; }
}
```
What causes this?
Thanks,
Jan
I am trying to integrate this example in my work. But I run into a problem with my entities.
I get this when accessing my repository on an entity:
> System.InvalidOperationException: The entity type Estate is not part of the model for the current context.
In the Repository.cs:
```
public virtual void Insert(TEntity entity)
{
((IObjectState)entity).ObjectState = ObjectState.Added;
_dbSet.Attach(entity); // <-- The error occurs here
_context.SyncObjectState(entity);
}
```
This is my DbContext:
```
public partial class DimensionWebDbContext : DbContextBase
{
public DimensionWebDbContext() :
base("DimensionWebContext")
{
Database.SetInitializer<DimensionWebDbContext>(new CreateDatabaseIfNotExists<DimensionWebDbContext>());
Configuration.ProxyCreationEnabled = false;
}
public new IDbSet<T> Set<T>() where T : class
{
return base.Set<T>();
}
}
```
And the Entity:
```
public class Estate : EntityBase
{
public int Id { get; set; }
public string Name { get; set; }
public string Subject { get; set; }
public DateTime DateAdded { get; set; }
public Status Status { get; set; }
public decimal GrossArea { get; set; }
public decimal NetArea { get; set; }
public decimal CommenArea { get; set; }
public int Year { get; set; }
public int Rooms { get; set; }
public bool Balcony { get; set; }
public decimal Price { get; set; }
public decimal Payment { get; set; }
public virtual EstateAddress Address { get; set; }
public virtual EstateType Type { get; set; }
}
```
What causes this?
Thanks,
Jan