4

我正在使用 Visual Studio 2010、Entity Framework 4 和模型优先开发。
我在 VS EDM 设计器中建模,然后自定义编辑了我的 edmx 文件,以便表名是大写的(不是我的选择,DBA 对名称大小写敏感的数据库的要求)。即 edmx ssdl 条目将如下所示:

<EntitySet Name="MESSAGES" EntityType="SIMPLEPIX.STORE.MESSAGES" store:Type="Tables" Schema="MW_ARCHIVE" Table="MESSAGES" />

然后我在设计器中右键单击以“从模型生成数据库......”这会做两件事。首先,它将我所有的 edmx 编辑恢复为驼峰式。即上面的行变成:

<EntitySet Name="Messages" EntityType="SimplePix.Store.Messages" store:Type="Tables" Schema="MW_ARCHIVE" />

(并注意我的Table="MESSAGES"属性已被删除)。

其次,它创建以下 DDL:

[snip]
IF OBJECT_ID(N'[MW_ARCHIVE].[MESSAGES]', 'U') IS NOT NULL
    DROP TABLE [MW_ARCHIVE].[MESSAGES];
[snip]
CREATE TABLE [MW_ARCHIVE].[Messages] (
[snip]

没错:它知道必须删除 MESSAGES(大写),但随后又想创建 Messages(驼峰式)。

如何让 VS 不理会我的 edmx 编辑并生成正确的(大写)DDL?非常感谢。

4

2 回答 2

0

It says this at the top of your POCO classes (if that's what you're using

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated from a template.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

Whenever you regenerate your code any changes you made will be overwritten, every time without fail

I'm not saying it cannot be done through some obscure methods or tool, but none that I personally am aware of.

If you're tables have to be uppercase why not make then uppercase on the DB server? Or am I missing something here?

于 2011-02-05T12:58:49.590 回答
0

您不能修改 EF 生成的类,因为每次执行“从数据库模型生成”时它们都会被更改。我认为没有办法解决这个问题。

于 2011-02-04T18:25:21.780 回答