Is it possible to use the VS Entity Diagram design

2019-09-09 05:04发布

The introductory videos for ASP.NET MVC 3 imply that the desired workflow is for me to declare classes that define my model (code-first design).

This strikes me as weird, since Visual Studio has a nice Entity Diagram designer which can generate such classes with navigation properties, etc.

Is it possible to use that Entity Diagram designer to design the model (model-first design), and have ASP.NET MVC 3 understand the generated classes as its model?

Please provide precise steps if possible :) Thanks :)

2条回答
Luminary・发光体
2楼-- · 2019-09-09 05:29

Apparently it is not possible.

(Anyone wishing to prove me wrong and show how it can be done, please be my guest, but please provide steps :) )

查看更多
对你真心纯属浪费
3楼-- · 2019-09-09 05:36

Yes, this is called Model First design. Most of the video's you see have used the Code First approach. There are benefits to both.

This video should help you out.

http://msdn.microsoft.com/en-us/data/ff628199

UPDATE:

Here are the steps I use:

  1. Create new MVC Project, I use the default internet project.
  2. Right click on Models folder, Create new Entity Model (choose empty model)
  3. Drag an Entity onto the designer, name it User.
  4. Right click on designer and choose Generate Database
  5. Use context and entity in project.

It's not difficult, and it works just fine. And it works the same way Model First works anywhere else.

查看更多
登录 后发表回答