2

I have simple scenario:

  • Web Project(C#) with added dll reference to below DataSource project.
  • Separate DataSource project (Class Library) where I added edmx file and generated POCOs with DbContext Generator.

Really, nothing special. I think every youtube instructional video I saw on Entity Framework is doing something simple.

What I discovered is that EntityDataSource simply doesn't work. I get range of error messages and I really can't see the pattern when they are showing up:

Here are some:
- Unable to load the specified metadata source
- Schema invalid and types cannot be loaded because the assembly contains EdmSchemaAttribute... loading by both name and attribute is not allowed.

Few time, don't know how, I managed to pass by this error, in that case I would get CLR error when I try to execute simple page with datasource and gridview (nothing was coded)

End to add to the problem... I am referencing another DataSource project the same way. I am perfectly able to set this EntityDataSource without errors above. But when I click Refresh Schema, I get error "Could not find the CLR type for MyEntity.

What is wrong here.

Thanks

bobetko
  • 5,019
  • 14
  • 58
  • 85

1 Answers1

0

I was getting the EdmSchemaAttribute error message, using EF 5.0 and WCF Data Services 5.2.0. This was a data service using a DbContext-derived class, but the DbContext-derived class was in the same assembly as some EDMX files and ObjectContext-based code generated from the EDMX files.

The fix for me was to separate code-first EF code from model-first EF code (which uses ObjectContext and generates code with the [EdmSchema] attribute). By moving the code-first code into a separate assembly, the error message went away and things are working.

I hope that helps.

crimbo
  • 10,308
  • 8
  • 51
  • 55