简体   繁体   English

如何使用 C# 中的数据库优先方法生成具有所有 CRUD 操作的存储库和模型/实体类

[英]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.

相关问题 C#实体框架(代码优先),在模型上实现CRUD操作 - C# Entity Framework (Code first), Implementing CRUD Operations on Model Entity Framework 6.2.0不生成某些类(数据库优先) - Entity Framework 6.2.0 does not generate some classes(database-first) 是否可以从数据库优先的C#类生成SQL脚本? - Is it possible to generate SQL script from database-first generated C# classes? 对数据库优先实体框架模型的更改 - Changes to a database-first Entity Framework model 存储库模式使用实体框架,代码优先和CRUD操作 - Repository Pattern using Entity Framework, code first and CRUD operations 如何使用C#以数据库优先方式拥有审核列? - How can I have audit columns in a database-first approach using c#? 在实体框架中刷新使用数据库优先方法模型创建的实体中的数据 - Refresh the data in entity created using database-first approach model in Entity Framework 通过实体框架连接的Oracle数据库错误(C#VS 2015数据库优先)错误 - Oracle datebase connectced through Entity Framework ( C# VS 2015 database-first) error 实体框架数据库优先不能创建正确的模型 - Entity Framework database-first doesn't create the correct model 根据数据库优先实体模型验证条目长度 - Validate entry length based on database-first entity model
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM