从数据库创建模型时,从表名更改实体名称/ poco类名称 [英] Changing entity name/poco class name from table name while creating model from the database

查看:148
本文介绍了从数据库创建模型时,从表名更改实体名称/ poco类名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从现有的数据库创建一个实体模型,但所有的表名都在数据库中包含_/下划线,所以在创建poco类时,我想从实体/ poco类的名称中删除下划线。在从数据库创建模型期间在实体框架中创建实体时,是否有一种方法来更改命名约定?

感谢
Amit

解决方案

您有两个选项,


  1. 是一点学习曲线,但它涉及使用T4模板自己做代码生成。基本上你将在概念模型中剥离_。 定制实体指南类

  2. 更简单,更难的是只需导入模型,然后使用模型浏览器并重命名每个实体。你只需要做一次,它将把映射从概念保存到物理。可以通过这里(搜索更改实体名称)


I want to create a entity model from the existing database but all the table names contain "_"/underscore in the database so while creating poco classes i want remove underscore from name of the entities/poco classes. Is there a way to change the naming convention while the entities are created in the entity framework during the creation of model from database

Thanks, Amit

解决方案

You have two options,

  1. There is a little bit of a learning curve but it involves using T4 templates to do the code generation yourself. Basically you would just strip out the _ in the conceptual model. guide to customizing entity classes
  2. Easier, and a little more painful is to just import your model and then use the model explorer and rename each entity. You will only have to do this once, it will save the mapping from conceptual to physical. A walk through can be found here (search for "Changing an entity name")

这篇关于从数据库创建模型时,从表名更改实体名称/ poco类名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆