EF 6数据库优先 - 删除表前缀 [英] EF 6 Database First - Removing table prefix

查看:55
本文介绍了EF 6数据库优先 - 删除表前缀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有数据库,其表格的前缀为


ex:tbl_mytable1



我想使用实体框架6,但是当我从我的数据库生成模型(我使用.edmx文件从数据库模式生成模型)时,前缀包含在模型名称中。$


ex: - 公共部分类tbl_mytable1 



如何配置实体框架以删除模型名称的前缀?

I have an existing database with tables that have a prefix

ex : tbl_mytable1

I want to use entity framework 6, but When I generate models ( I am using an .edmx file to generate models from the database schema ) from my database, the prefix is included in the model name.

ex: - public partial class tbl_mytable1 

How do I configure entity framework to remove the prefix from the model name?

例如:它应该显示为mytable1而不是tbl_mytable1。 

Ex: It should appear as mytable1 instead of tbl_mytable1. 

推荐答案

您好SANTOSH PHA PE,

您可以通过EDMX实体属性更改名称。像这样:

you could change the name via EDMX entities property. like this:

#Usage:

 using (var db = new EF20161102Entities())
            {
                var t1 = new mytable1() { Id = 2, Name = "Test2" };

                db.mytable1.Add(t1);

                db.SaveChanges();
            }

#Result

祝你好运,

Cole Wu


这篇关于EF 6数据库优先 - 删除表前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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