How to split entity classes in a separate project from Entity Framework in easy step

Dear All,

Below are easy step to split the entity classes in a separate project. I have created a MVC sample project in below example. Now follow below steps

Step 1:- Add  a Ado.NET Entity Data Model  as shown below. I am using SQL Server “Friends” Database in this example.defaultedm 

Step 2:-

Once EDMX is added I got below structure as shown in below figure. Entities for each table object of Friends Database shown in below fig

defaultedmx

Step 3:- Now as our goal to separate this entity class  I added a new class project as shown in below figure

pocoentities

Step 4:-

Now in this class project add  EF 5.x Db Context Generator  as shown in below figure

newEFDbContextGenerator

Step 5:-

Now  click on Model.tt file in your new class project. Just edit  the Input file  as I edited in below fix you need to give your EDMX Path. 

Like I did “ using string inputFile = @”..\youredmxprojectname\youredmxname.edmx”

changethePathofEdmx

Step 6:-   Once this code is changed delete the all the  entities files from EDMX and rebuild  the project

Step 7:-  Once the file is generated you are good to go  just see as I got the files  in separate class project.

 

generatedEntities

I hope you will achieve the same with above steps.

So enjoy learning Smile

Your Host,

Rajat Jaiswal

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s