This code will get them for you, of course the ones that has been imported to your EDM which necessarily is not all the tables in your data store.
var tableNames = context.MetadataWorkspace.GetItems(DataSpace.SSpace)
.Select(t => t.Name)
.ToList();
For code first:
using System.Data.Metadata.Edm;
using System.Data.Objects;
using System.Data.Entity.Infrastructure;
...
using (dbcontext context = new TestContext())
{
ObjectContext objContext = ((IObjectContextAdapter)context).ObjectContext;
MetadataWorkspace workspace = objContext.MetadataWorkspace;
IEnumerable<EntityType> tables = workspace.GetItems<EntityType>(DataSpace.SSpace);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…