简体   繁体   English

实体框架将现有类添加到实体框架模型图

[英]Entity framework adding existing classes to Entity Framework Model Diagram

Hi I'm new to Entity Framework so excuse me if this question seem simple, but I have tried to find an example or question where this is described. 嗨,我是Entity Framework的新手,如果这个问题看起来很简单,请原谅,但是我试图找到一个示例或描述此问题的问题。

I have built a webApi interface with classes in what I call an eventmodell. 我用所谓的eventmodell中的类构建了一个webApi接口。 The Interface and model is working well to receive stuff. 接口和模型可以很好地接收东西。 But now I would like to build the CRUD functions to the database with Entity Framework. 但是现在我想使用实体框架为数据库构建CRUD函数。

I have added an empty code first model, but then I don't now how to generate csdl, msl and ssl files needed to create the database. 我先添加了一个空代码模型,但是现在我不知道如何生成创建数据库所需的csdl,msl和ssl文件。

I have added Empty EF designer model but have found no way of adding an existing class to the designer. 我已经添加了Empty EF设计器模型,但是没有找到向设计器添加现有类的方法。

I have installed EF Power Tools but that didn't help. 我已经安装了EF Power Tools,但这没有帮助。

You seem to have a misunderstanding on how Code First works as compared to Database First. 与数据库优先相比,您似乎对代码优先的工作方式有误解。

There is no designer needed in a Code First approach. 代码优先方法不需要设计师。 You add classes to your model, setup a DbContext and use Migrations to setup, and then at later stages, alter the database structure. 您将类添加到模型中,设置DbContext并使用Migrations进行设置,然后在以后的阶段更改数据库结构。

Checkout this tutorial: Getting Started with Entity Framework 6 Code First using MVC 5 查看本教程: 使用MVC 5的Entity Framework 6 Code First入门

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM