# IT:AD:Code First #
* [[../|(UP)]]
{{indexmenu>.#2|nsort tsort}}
---
## Example ##
public class EFRepository : IGraphRepository>
{
private readonly GraphContext _graphContext = new GraphContext();
public void Persist(params GraphVertex[] vertices)
{
foreach(GraphVertex vertex in vertices)
{
bool isDetached = ((int)_graphContext.Entry(vertex).State).BitIsSet((int)EntityState.Modified);
if (vertex.Id == default(int))
{
_graphContext.Vertices.Add(vertex);
}
else
{
_graphContext.Vertices.Attach(vertex);
_graphContext.Entry(vertex).State = EntityState.Modified;
}
}
_graphContext.SaveChanges();
}
}
}