[英]how to generate the Repository and model/entity classes with all CRUD operations using database-first apporach in C#
I have a database for which I want to generate the repository and entity/model classes with all CRUD operations.我有一个数据库,我想为它生成包含所有 CRUD 操作的存储库和实体/模型类。 To achieve this I found a tool, named Entity Developer ( https://www.devart.com/entitydeveloper/download.html ), which is generating all the stuff, but without CRUD operation for each entity as tools is generating just an empty class named ABCRepository, so again I have to write the code for each repository class.
为了实现这一点,我找到了一个名为 Entity Developer ( https://www.devart.com/entitydeveloper/download.html ) 的工具,它正在生成所有东西,但没有为每个实体进行 CRUD 操作,因为工具只生成一个空class 命名为 ABCRepository,所以我必须再次为每个存储库 class 编写代码。 Though same task can be achieved from Entity framework, except than the repository classes( which does not contain any CRUD operations).
尽管可以从 Entity 框架完成相同的任务,但存储库类(不包含任何 CRUD 操作)除外。
Can any one help me to get the solution?任何人都可以帮助我获得解决方案吗?
Update: I have followed this tutorial ( https://dzone.com/articles/implementing-the-repository-pattern-using-c-and-en ), according to this, Entity Developer should generate the "Repository per entity type" with operations, but while following and creating the Data Model, I get only empty ABCRespository and IABCRepository classes.更新:我已按照本教程( https://dzone.com/articles/implementing-the-repository-pattern-using-c-and-en ),据此,实体开发人员应该生成“每个实体类型的存储库”使用操作,但在关注和创建数据 Model 时,我只得到空的 ABCRespository 和 IABCRepository 类。 I tried multiple ways to create the Data Model, yet not successful.
我尝试了多种方法来创建数据 Model,但没有成功。
To achieve this I found a tool, named Entity Developer ( https://www.devart.com/entitydeveloper/download.html ), which is generating all the stuff, but without CRUD operation for each entity as tools is generating just an empty class named ABCRepository
为了实现这一点,我找到了一个名为 Entity Developer ( https://www.devart.com/entitydeveloper/download.html ) 的工具,它正在生成所有东西,但没有为每个实体进行 CRUD 操作,因为工具只生成一个空class 命名为 ABCRepository
Please check the Generate Partial property of your Repository And Unit of Work template.请检查您的存储库和工作单元模板的生成部分属性。 If it is set to True (by default), the code is generated in ABCRepository.Generated.cs.
如果设置为 True(默认情况下),则在 ABCRepository.Generated.cs 中生成代码。 The code file ABCRepository.cs is created for user code that will not be overwritten by the designer.
代码文件 ABCRepository.cs 是为不会被设计者覆盖的用户代码创建的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.