none
how to seperate classes from EF 5 RRS feed

  • Question

  • Hi ,

    Im begineer in Entity framework 5.

    I want to know is there any way that i can seperate classes from EF layer and paste them to another class library and then call those classes in my business layer project and use the DAL function made by EF from another project to do - just like in n tier architecture.

    Thanks

    Tuesday, September 4, 2012 6:52 PM

Answers

  • Assuming you use database first, I see nothing else than moving the EDMX file from your main project to your class library (as well as the config file to still have the connectionstring handy for design time tools). You may have perhaps to adjust the namespace as the DLL will have another default namespace. Also you'll set a reference from your main project to your other class library project (likely you'll want them in the same solution at least to start with). Of course you'll need also to add the proper references on your newly created class library project.

    Or another option could be to copy this project and if I remember you can change the project type and remove all that doesn't belong to the project to create your class library project.

    I don't expect something really special or tricky else I would have to try to se if I hit something special. If you tried something please post about your particular problem rather than to ask for general guidelines (others may have never seen your issue). Or are you just unfamiliar with class library projects ?


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".

    Wednesday, September 5, 2012 12:50 PM

All replies

  • Hi,

    Sure, just create a class library. What have you tried that doesn't work ? The only thing I can think of is that in this case you have to copy the connection string written at design time to the config file for the class library project to the config file for your main application. Other than that it shouldn't differ from usual class librairies...


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".

    Wednesday, September 5, 2012 10:50 AM
  • Hi ,

    My code generation strategy in EF5 in default. Can you tell me in details that which files i have to cut from EF 5 files in order to seperate those classes with their DAL functions and put in another project. So that i can call those classes and do some work and than DAL functions from EF project.

    Thanks

    Wednesday, September 5, 2012 11:32 AM
  • Assuming you use database first, I see nothing else than moving the EDMX file from your main project to your class library (as well as the config file to still have the connectionstring handy for design time tools). You may have perhaps to adjust the namespace as the DLL will have another default namespace. Also you'll set a reference from your main project to your other class library project (likely you'll want them in the same solution at least to start with). Of course you'll need also to add the proper references on your newly created class library project.

    Or another option could be to copy this project and if I remember you can change the project type and remove all that doesn't belong to the project to create your class library project.

    I don't expect something really special or tricky else I would have to try to se if I hit something special. If you tried something please post about your particular problem rather than to ask for general guidelines (others may have never seen your issue). Or are you just unfamiliar with class library projects ?


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".

    Wednesday, September 5, 2012 12:50 PM