Visual Studio and Entity Framework edmx: My custom changes are overwritten

I am using Visual Studio 2010, Entity Framework 4 and the first model.
I modeled in the VS EDM design, then the user edited my edmx file so that the table names were uppercase (not my choice, DBA requirement for a name-sensitive database). that is, the edmx ssdl entry would look like this:

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

Then I right-click in the designer to "Create a database from the model ..." This does 2 things. First, it pushes all my edmx changes back to the camel body. That is, the line above becomes:

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

(and note that my Table = "MESSAGES" attribute has been removed).

Secondly, it creates the following 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] 

That's right: he knows that he needs to discard the MESSAGES (in upper case), but then wants to create Messages (case of a camel).

How can I make VS leave my edmx changes on my own and create the correct (uppercase) DDL? Very grateful.

+4
source share
2 answers

you cannot change the classes generated by EF, because they will change every time you run the Create from Database command. I don’t think there is a way around this.

0
source

He says this at the top of your POCO classes (if that's what you use

 //------------------------------------------------------------------------------ // <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 update your code, any changes you make will be overwritten, each time without crashing

I am not saying that this cannot be done with some obscure methods or tools, but none of them are personally known to me.

If you need to be uppercase, why not capitalize on the database server? Or am I missing something here?

0
source

Source: https://habr.com/ru/post/1338469/


All Articles