询问者
EF在添加实体后,保存时生成两个cs文件,为什么,怎么修改?

问题
全部回复
-
是不是你在每个程序中都会生成多个CS文件,这个貌似不太可能出现的情况,除非你自己以前有自定化T4模板。
Alan Chen[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
-
你是在EDMX上添加一个实体就会自动的多一个.cs的文件出来?
Alan Chen[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
-
在默认的情况下,每次添加一个实体类的时候,这个实体类是将出现在.Designer.cs这个文件,你应该是用了个想要的Code Item 来生成POCO,或者Dbcontext。
请你查看你的Model.tt文件中有没有类似这样的代码:
// Emit Entity Types foreach (EntityType entity in ItemCollection.GetItems<EntityType>().OrderBy(e => e.Name)) { fileManager.StartNewFile(entity.Name + ".cs"); BeginNamespace(namespaceName, code); WriteEntityTypeSerializationInfo(entity, ItemCollection, code, ef);
Alan Chen[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
-
你是在EDMX上添加一个实体就会自动的多一个.cs的文件出来?
Alan Chen[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
-
朋友呀,我完全不懂你的意思,重新生成是指什么?来点截图吧!
Alan Chen[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
-
朋友呀,我完全不懂你的意思,重新生成是指什么?来点截图吧!
Alan Chen[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
看到了吧,我现在生成的名称是TescommModels1.Designer.cs了,不是TescommModels.Designer.cs