Print Page | Close Window

Code Second

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3582
Printed Date: 22-Jan-2026 at 3:16am


Topic: Code Second
Posted By: Vonzkie
Subject: Code Second
Date Posted: 16-Aug-2012 at 5:34pm
Hi,

I'm playing around with the Code Second approach w/c is basically a Code First. :)
Now, I want to ask some questions:

1. How can I create a concrete base class that implements IEntity because we need to occasionally check EntityAspect class.
I checked the tutorial here  http://drc.ideablade.com/xwiki/bin/view/Documentation/code-sample-code-first-walk - http://drc.ideablade.com/xwiki/bin/view/Documentation/code-sample-code-first-walk  but the base class here throws a not implemented exception on the getter of the EntityAspect. Can I have real world example here? We need a base class that behaves like the Devforce Entity base class.

2. Is IDataSourceKeyResolver still applicable in Code First to dynamically compose connections string?
3. It seems that we have lots of breaking changes in our codes cause we're using the Devforce Entity class as the generic parameter for few repository classes. Do you have some advise on how we can easily migrate from Database First to Code First without having to completely rewrite our codes? 
4. What are the other things that we might encounter in migrating or upgrading to Code First from Database First as far as coding is concern?

Thanks,
Von



Replies:
Posted By: Vonzkie
Date Posted: 17-Aug-2012 at 12:33am
For #2, I checked this article  http://drc.ideablade.com/xwiki/bin/view/Documentation/advanced-database-connections - http://drc.ideablade.com/xwiki/bin/view/Documentation/advanced-database-connections  and I didn't find a way to dynamically compose connection string like IDataSourceKeyResolver does.

Btw, I choose to use EntityManager over DBContext.

Can you help me on this cause IDatasourceKeyResolver is not firing anymore when I convert my model to Code First.

Thanks,
Von


Posted By: sbelini
Date Posted: 20-Aug-2012 at 1:22pm
Hi Von,
 
1. The tempHire Cocktail sample will give you an example of a base class. Have you taken a look at it?
 
2. You should be able to use IDataSourceKeyResolver without problems. Please provide a small solution reproducing your issue, so we can check what's wrong.
 
Silvio.
 
 



Print Page | Close Window