New Posts New Posts RSS Feed: Code First Base Class
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Code First Base Class

 Post Reply Post Reply
Author
Vonzkie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 01-Aug-2011
Location: PH
Posts: 133
Post Options Post Options   Quote Vonzkie Quote  Post ReplyReply Direct Link To This Post Topic: Code First Base Class
    Posted: 22-Aug-2012 at 1:16am
Hi

I created a base class for all my Code First Entities and I put the base class in a separate project or assembly.
Now, using Code Second Approach, I enter the inject base class like 'OtherProject.EntityBase' and it generates all the codes and I was able to compile the whole project.
When I try to execute the query like:

var context = new DomainEntities(some parameters here);
var result = context.Sample.ToList();

This error will show:

Unable to get metadata for  OtherProject.EntityBase . Make sure it is a valid entity type or POCO type with a KeyAttribute

Am I missing something?

Do i need to have a metadata (ibmmx) or something before it work?

Thanks,
Von
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 23-Aug-2012 at 1:29pm
Von,
 
I was not able to reproduce it here.
I'm sending the CodeFirstWalk sample modified so the base class is in a different assembly.
 
Regards,
   Silvio.
Back to Top
Vonzkie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 01-Aug-2011
Location: PH
Posts: 133
Post Options Post Options   Quote Vonzkie Quote  Post ReplyReply Direct Link To This Post Posted: 23-Aug-2012 at 4:25pm
Hi Silvio,

I'm not sure if this is related but I don't have a custom DBContext, I only use EntityManager and I'm in an n-Tier environment so I have a BOS here.

Thanks,
Von
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 23-Aug-2012 at 4:55pm
Von,
 
A Code First model without a DbContext worked as well. (see sample: uploads/892/Silverlight_CodeFirstTourOfDevForce_BaseClassInDifferentAssembly.zip)
 
When you have the base class in the same assembly, does it work?
When you build, is the .ibmmx file generated?
 
Note that Code Second might not produce a 100% working code and you might have to make little changes to it.
 
Silvio.


Edited by sbelini - 23-Aug-2012 at 4:56pm
Back to Top
Vonzkie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 01-Aug-2011
Location: PH
Posts: 133
Post Options Post Options   Quote Vonzkie Quote  Post ReplyReply Direct Link To This Post Posted: 23-Aug-2012 at 5:02pm
When you have the base class in the same assembly, does it work?
- Yes it worked
- The weird thing here is that, I just transferred the base class to a different assembly and now it doesn't work.

When you build, is the .ibmmx file generated?
- Yes, in the Model project not in the BaseClass project


Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 23-Aug-2012 at 10:38pm
Von,
 
Please provide a reproducible test case.
 
Silvio.
Back to Top
Vonzkie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 01-Aug-2011
Location: PH
Posts: 133
Post Options Post Options   Quote Vonzkie Quote  Post ReplyReply Direct Link To This Post Posted: 27-Aug-2012 at 11:13pm
Hi Silvio,

I found the culprit. :)
I forgot to include the Base Class Assembly into my Search Composition List. 

Thanks,
Von
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down