Get name of all available classes under model.tt : Entity Framework 6

277 views Asked by At

I want to get all available classes name those are listed under Model.tt.

I have tried below piece of code to get them but that is giving only table name not complex types which are imported via stored procedure:

var x = ((IObjectContextAdapter)d).ObjectContext.MetadataWorkspace.GetItems<EntityType>(DataSpace.CSpace); // d is my context object.

I have tried all available options of DataSpace enum with no luck.

Above code only returns table name like Employee, Department but I want to get complex types as well like USP_GetDepartments_Result, USP_GetAllEmployee_Result which are complex types generated from stored procedure.

I am using EntityFrameWork version 6. I have searched on StackOverflow but did not get result related to stored procedure part.

1

There are 1 answers

0
Priyank Sheth On BEST ANSWER

Finally I got my result by below line of code:

((IObjectContextAdapter)d).ObjectContext.MetadataWorkspace.GetItems(DataSpace.CSpace)

Its giving me all the types of object context. Then I filtered them and got complex types.