开发者

Entity Data Model - export to other solutions in visual studio

开发者 https://www.devze.com 2023-03-02 02:45 出处:网络
a newbie question here... I\'ve created an entity data model (.edmx) file in one project and now it\'s sitting there looking beautiful with complex types defined and diagrams all spaced properly..

a newbie question here...

I've created an entity data model (.edmx) file in one project and now it's sitting there looking beautiful with complex types defined and diagrams all spaced properly..

Then I started a new project and try to reuse the same file by adding it to the project... I get a bunch of errors sayings it's not pointing to the right pro开发者_开发技巧ject...

I tried to just copy the entire model into a new model and get a bunch of reference errors.

How do I do this? surely it can't be this hard...

I can of course import from the database but I don't get the complex types etc and remapping them is PIA.


You shouldn't have to import the model if you love what you just did... if you create a New Solution, you can "Add Existing Project" and it will transfer properly.

  1. Create a new solution
  2. Add Existing Project (Then select the project with the pretty .edmx)
  3. Add new Project to solution (the new project you want to do... MVC, Forms, ASP, UnitTest etc.)
  4. Reference the first project with the .edmx into the newly created project

Just make sure your connection strings are set correctly when you do this

This will keep the EF logic separate from the new project... Plus that project becomes reusable in other projects if that's what you want...

This will also keep you on the Onion Architechture path...

0

精彩评论

暂无评论...
验证码 换一张
取 消