0

So I have this other question here: Entity Framework - Determine the HasDatabaseGeneratedOption setting for a given type

I think to answer that question I just need to get access to the Storage Model (the one that is created with OnModelCreating) for a given DbContext.

Any ideas?

Community
  • 1
  • 1
Anthony Nichols
  • 1,586
  • 2
  • 25
  • 50

1 Answers1

4

from a given dbcontext...you can do this

var mw = ((IObjectContextAdapter)context).ObjectContext.MetadataWorkspace; 

see this https://msdn.microsoft.com/en-us/library/system.data.metadata.edm.metadataworkspace_methods(v=vs.110).aspx

to access the Storage Model you can do this:

var sSpaceEntities = (StoreItemCollection)mw.GetItemCollection(DataSpace.SSpace);

se this for DataSpace avaiables https://msdn.microsoft.com/en-us/library/system.data.metadata.edm.dataspace(v=vs.110).aspx

and you can play around with this objects while debbuging, there is a lot of information you can find.

George
  • 777
  • 7
  • 17