Entity Framework - only edmx without templates The Next CEO of Stack OverflowSplitting EDMX ModelEntity Framework vs LINQ to SQLHow to create Excel (.XLS and .XLSX) file in C# without installing Ms Office?How do I get a consistent byte representation of strings in C# without manually specifying an encoding?Interface defining a constructor signature?SqlException from Entity Framework - New transaction is not allowed because there are other threads running in the sessionEntity Framework TimeoutsEntity Framework 5 stopped running T4 templates files on saveEntity Framework 5 Updating a RecordStored Procedures and updating EDMXEntity Framework refresh didn't update the Table properly

Compensation for working overtime on Saturdays

Do I need to write [sic] when including a quotation with a number less than 10 that isn't written out?

What happens if you break a law in another country outside of that country?

How dangerous is XSS

Is the offspring between a demon and a celestial possible? If so what is it called and is it in a book somewhere?

Can Sri Krishna be called 'a person'?

Calculate the Mean mean of two numbers

Oldie but Goldie

Can you teleport closer to a creature you are Frightened of?

Can I hook these wires up to find the connection to a dead outlet?

How can the PCs determine if an item is a phylactery?

What difference does it make matching a word with/without a trailing whitespace?

My ex-girlfriend uses my Apple ID to login to her iPad, do I have to give her my Apple ID password to reset it?

Would a grinding machine be a simple and workable propulsion system for an interplanetary spacecraft?

Incomplete cube

How did scripture get the name bible?

Mathematica command that allows it to read my intentions

Arrows in tikz Markov chain diagram overlap

Why do we say “un seul M” and not “une seule M” even though M is a “consonne”?

Is the 21st century's idea of "freedom of speech" based on precedent?

Are British MPs missing the point, with these 'Indicative Votes'?

How to show a landlord what we have in savings?

Why can't we say "I have been having a dog"?

How to pronounce fünf in 45



Entity Framework - only edmx without templates



The Next CEO of Stack OverflowSplitting EDMX ModelEntity Framework vs LINQ to SQLHow to create Excel (.XLS and .XLSX) file in C# without installing Ms Office?How do I get a consistent byte representation of strings in C# without manually specifying an encoding?Interface defining a constructor signature?SqlException from Entity Framework - New transaction is not allowed because there are other threads running in the sessionEntity Framework TimeoutsEntity Framework 5 stopped running T4 templates files on saveEntity Framework 5 Updating a RecordStored Procedures and updating EDMXEntity Framework refresh didn't update the Table properly










1















We would like to add only .EDMX files without corresponding .tt files for context and entities. There is multiple reasons for this, but long story short - we would like to be able to have .EDMX and be able to refresh it from DB when needed.



Currently if I delete .tt files every time I "Update from DB" it will regenerate .tt files and entitites which we don't need.










share|improve this question






















  • Have you tried keeping the .tt files but deleting their content?

    – yv989c
    Mar 21 at 20:36











  • Yes. And it would be "kind of" ok but code becomes somewhat "dirty" with extra empty files under each EDMX ModelA.context.tt, ModelA.Context.cs, ModelA.tt, ModelA.cs.

    – katit
    Mar 21 at 20:53











  • Just curious: Whats the goal, behind having an EDMX, but no T4 templates, and therefore no Context and Entities? If it's database visualisation, aren't there better tools out there? And why not simple create a new project for the visualization?

    – Christian Gollhardt
    Mar 21 at 21:22











  • It's a long story, but basically T4s don't do what we need. We need multi-files generated for different purposes. So, we will have contexts and entities but going to handle generation in our own code (based off EDMX) without using T4s. We can make T4s work I assume but with complexity of what we do it seems that going our own generator will be more maintainable

    – katit
    Mar 21 at 22:13











  • I am not exactly sure, but couldn't you make you own generator a Custom Tool (its a property of the edmx) for the edmx? Take a look here, not that I have done that.

    – Christian Gollhardt
    Mar 21 at 23:39
















1















We would like to add only .EDMX files without corresponding .tt files for context and entities. There is multiple reasons for this, but long story short - we would like to be able to have .EDMX and be able to refresh it from DB when needed.



Currently if I delete .tt files every time I "Update from DB" it will regenerate .tt files and entitites which we don't need.










share|improve this question






















  • Have you tried keeping the .tt files but deleting their content?

    – yv989c
    Mar 21 at 20:36











  • Yes. And it would be "kind of" ok but code becomes somewhat "dirty" with extra empty files under each EDMX ModelA.context.tt, ModelA.Context.cs, ModelA.tt, ModelA.cs.

    – katit
    Mar 21 at 20:53











  • Just curious: Whats the goal, behind having an EDMX, but no T4 templates, and therefore no Context and Entities? If it's database visualisation, aren't there better tools out there? And why not simple create a new project for the visualization?

    – Christian Gollhardt
    Mar 21 at 21:22











  • It's a long story, but basically T4s don't do what we need. We need multi-files generated for different purposes. So, we will have contexts and entities but going to handle generation in our own code (based off EDMX) without using T4s. We can make T4s work I assume but with complexity of what we do it seems that going our own generator will be more maintainable

    – katit
    Mar 21 at 22:13











  • I am not exactly sure, but couldn't you make you own generator a Custom Tool (its a property of the edmx) for the edmx? Take a look here, not that I have done that.

    – Christian Gollhardt
    Mar 21 at 23:39














1












1








1








We would like to add only .EDMX files without corresponding .tt files for context and entities. There is multiple reasons for this, but long story short - we would like to be able to have .EDMX and be able to refresh it from DB when needed.



Currently if I delete .tt files every time I "Update from DB" it will regenerate .tt files and entitites which we don't need.










share|improve this question














We would like to add only .EDMX files without corresponding .tt files for context and entities. There is multiple reasons for this, but long story short - we would like to be able to have .EDMX and be able to refresh it from DB when needed.



Currently if I delete .tt files every time I "Update from DB" it will regenerate .tt files and entitites which we don't need.







c# .net entity-framework-6






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 21 at 20:05









katitkatit

7,24129105219




7,24129105219












  • Have you tried keeping the .tt files but deleting their content?

    – yv989c
    Mar 21 at 20:36











  • Yes. And it would be "kind of" ok but code becomes somewhat "dirty" with extra empty files under each EDMX ModelA.context.tt, ModelA.Context.cs, ModelA.tt, ModelA.cs.

    – katit
    Mar 21 at 20:53











  • Just curious: Whats the goal, behind having an EDMX, but no T4 templates, and therefore no Context and Entities? If it's database visualisation, aren't there better tools out there? And why not simple create a new project for the visualization?

    – Christian Gollhardt
    Mar 21 at 21:22











  • It's a long story, but basically T4s don't do what we need. We need multi-files generated for different purposes. So, we will have contexts and entities but going to handle generation in our own code (based off EDMX) without using T4s. We can make T4s work I assume but with complexity of what we do it seems that going our own generator will be more maintainable

    – katit
    Mar 21 at 22:13











  • I am not exactly sure, but couldn't you make you own generator a Custom Tool (its a property of the edmx) for the edmx? Take a look here, not that I have done that.

    – Christian Gollhardt
    Mar 21 at 23:39


















  • Have you tried keeping the .tt files but deleting their content?

    – yv989c
    Mar 21 at 20:36











  • Yes. And it would be "kind of" ok but code becomes somewhat "dirty" with extra empty files under each EDMX ModelA.context.tt, ModelA.Context.cs, ModelA.tt, ModelA.cs.

    – katit
    Mar 21 at 20:53











  • Just curious: Whats the goal, behind having an EDMX, but no T4 templates, and therefore no Context and Entities? If it's database visualisation, aren't there better tools out there? And why not simple create a new project for the visualization?

    – Christian Gollhardt
    Mar 21 at 21:22











  • It's a long story, but basically T4s don't do what we need. We need multi-files generated for different purposes. So, we will have contexts and entities but going to handle generation in our own code (based off EDMX) without using T4s. We can make T4s work I assume but with complexity of what we do it seems that going our own generator will be more maintainable

    – katit
    Mar 21 at 22:13











  • I am not exactly sure, but couldn't you make you own generator a Custom Tool (its a property of the edmx) for the edmx? Take a look here, not that I have done that.

    – Christian Gollhardt
    Mar 21 at 23:39

















Have you tried keeping the .tt files but deleting their content?

– yv989c
Mar 21 at 20:36





Have you tried keeping the .tt files but deleting their content?

– yv989c
Mar 21 at 20:36













Yes. And it would be "kind of" ok but code becomes somewhat "dirty" with extra empty files under each EDMX ModelA.context.tt, ModelA.Context.cs, ModelA.tt, ModelA.cs.

– katit
Mar 21 at 20:53





Yes. And it would be "kind of" ok but code becomes somewhat "dirty" with extra empty files under each EDMX ModelA.context.tt, ModelA.Context.cs, ModelA.tt, ModelA.cs.

– katit
Mar 21 at 20:53













Just curious: Whats the goal, behind having an EDMX, but no T4 templates, and therefore no Context and Entities? If it's database visualisation, aren't there better tools out there? And why not simple create a new project for the visualization?

– Christian Gollhardt
Mar 21 at 21:22





Just curious: Whats the goal, behind having an EDMX, but no T4 templates, and therefore no Context and Entities? If it's database visualisation, aren't there better tools out there? And why not simple create a new project for the visualization?

– Christian Gollhardt
Mar 21 at 21:22













It's a long story, but basically T4s don't do what we need. We need multi-files generated for different purposes. So, we will have contexts and entities but going to handle generation in our own code (based off EDMX) without using T4s. We can make T4s work I assume but with complexity of what we do it seems that going our own generator will be more maintainable

– katit
Mar 21 at 22:13





It's a long story, but basically T4s don't do what we need. We need multi-files generated for different purposes. So, we will have contexts and entities but going to handle generation in our own code (based off EDMX) without using T4s. We can make T4s work I assume but with complexity of what we do it seems that going our own generator will be more maintainable

– katit
Mar 21 at 22:13













I am not exactly sure, but couldn't you make you own generator a Custom Tool (its a property of the edmx) for the edmx? Take a look here, not that I have done that.

– Christian Gollhardt
Mar 21 at 23:39






I am not exactly sure, but couldn't you make you own generator a Custom Tool (its a property of the edmx) for the edmx? Take a look here, not that I have done that.

– Christian Gollhardt
Mar 21 at 23:39













3 Answers
3






active

oldest

votes


















1





+150









If it's enough to have only the .edmx with two empty .tt files you can do that:



  1. Add the Entity Data Model (EF Designer from database)

  2. Cancel initial execution of the tools

  3. Empty Custom Tool value on each .tt file and on the .edmx file

  4. Delete contents of the .tt files if you want

  5. Delete .diagram file

After this steps, you can update your .edmx file and nothing happens.



Custom Tool emptyFinal solution






share|improve this answer























  • Looks like this is the best answer so far. You can ALSO delete .context.tt and it will "comply" with it. So, just Model1.tt required

    – katit
    Mar 25 at 15:52











  • The interesting part is, if I disable "Transform Related Text Templates On Save" after this steps, then I can delete all .tt files... Can you reproduce this too?

    – kapsiR
    Mar 25 at 15:59











  • @katit It seems that it is enough to just remove the Custom Tool from the .edmx file

    – kapsiR
    Mar 25 at 16:14











  • Nope. If I remove Model1.tt - it will recreate both .tt files on "update". Yes, I have "Transform.." disabled

    – katit
    Mar 25 at 16:23


















0














I'm not sure I understand fully, but I simply delete the pair of t4/tt files that are included with the model and the previously generated class files. They don't come back for EF6.



enter image description here



Then I delete them and I update model from database:



enter image description here



and they don't come back:



they don't come back



This is from EF 6.2:
enter image description here



Are you sure you're not dealing with some source control issue?






share|improve this answer

























  • We dont have Model1.Designer.cs and we don't have Model1.edmx.diagram. When we do "Update Model from Database" they come back. It's EF6.2

    – katit
    Mar 25 at 15:13











  • Using 6.2 also, the designer.cs file will get created but it's just got a comment: T4 code generation is enabled for model 'C:sourcereposConsoleApp2DataModel1.edmx'... Try adding a new model, repeat my steps to see...

    – reckface
    Mar 25 at 15:19











  • Just did that and it's restoring tts. I don't think it's source control because I can modify tts and then delete them after saving and it would restore with fresh unmodified tts. Also, when I do model I chose not to save connection string in .config and do the same on "update"

    – katit
    Mar 25 at 15:25











  • @katit it's actually impossible for .tt files to be regenerated. There's no mechanism in Visual Studio to recreate .tt files that are associated directly with the model. Tried this with EF5,even changing the Code Generation Strategy from T4, just creates db context

    – reckface
    Mar 25 at 16:50











  • Not sure what do you mean impossible. According to other posters and other answers - people are seeing same behaviour. If you delete .tt files and leave just .edmx - every time you "update" - VS/EF tool will recreate both .tt files.

    – katit
    Mar 25 at 16:52


















0














You can try this.



  1. Delete .tt files under your .edmx file.

  2. Project -> Add -> New Item -> EF 6.x DbContext Generator

  3. It will generate new .tt files. In these .tt files you can specify .edmx file path.
    enter image description here


  4. Run these .tt files to generate Model1 classes.


  5. Disable .tt files (Don't delete content as you will need it if you want to update your entities later. Usually they generate new files when you save them)
    enter image description here


  6. Update your .edmx (add/remove tables).


  7. This will not generate new .tt files under edmx

  8. And it will not update your entity classes.

  9. And if you want to update your entity classes, then run .tt files.

enter image description here



I tried this and "Update Model From Database" didn't generate new .tt files. So hopefully your problem will be solved.






share|improve this answer

























  • It would be kind of workaround, however we have multiple .edmx files and having separate templates for each will be messy

    – katit
    Mar 25 at 15:54











  • We have this solution in our workspace. Usually we have all edmx in one project (lets say DataLayer) and all entities in another project (Entities). This makes a separation and allows flexibility. Also we have modified our .tt to generate some custom code (like interfaces for classes).

    – fhnaseer
    Mar 25 at 16:03











  • @katit but with this solution, the tt files will now generate any .cs files so your problem will be solved. In fact, I think it's pretty difficult for .tt files to be autogenerated.

    – reckface
    Mar 25 at 16:04











  • The good thing is that you don't delete anything. You just keep them separate and update each component whenever you want.

    – fhnaseer
    Mar 25 at 16:06











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55288485%2fentity-framework-only-edmx-without-templates%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes









1





+150









If it's enough to have only the .edmx with two empty .tt files you can do that:



  1. Add the Entity Data Model (EF Designer from database)

  2. Cancel initial execution of the tools

  3. Empty Custom Tool value on each .tt file and on the .edmx file

  4. Delete contents of the .tt files if you want

  5. Delete .diagram file

After this steps, you can update your .edmx file and nothing happens.



Custom Tool emptyFinal solution






share|improve this answer























  • Looks like this is the best answer so far. You can ALSO delete .context.tt and it will "comply" with it. So, just Model1.tt required

    – katit
    Mar 25 at 15:52











  • The interesting part is, if I disable "Transform Related Text Templates On Save" after this steps, then I can delete all .tt files... Can you reproduce this too?

    – kapsiR
    Mar 25 at 15:59











  • @katit It seems that it is enough to just remove the Custom Tool from the .edmx file

    – kapsiR
    Mar 25 at 16:14











  • Nope. If I remove Model1.tt - it will recreate both .tt files on "update". Yes, I have "Transform.." disabled

    – katit
    Mar 25 at 16:23















1





+150









If it's enough to have only the .edmx with two empty .tt files you can do that:



  1. Add the Entity Data Model (EF Designer from database)

  2. Cancel initial execution of the tools

  3. Empty Custom Tool value on each .tt file and on the .edmx file

  4. Delete contents of the .tt files if you want

  5. Delete .diagram file

After this steps, you can update your .edmx file and nothing happens.



Custom Tool emptyFinal solution






share|improve this answer























  • Looks like this is the best answer so far. You can ALSO delete .context.tt and it will "comply" with it. So, just Model1.tt required

    – katit
    Mar 25 at 15:52











  • The interesting part is, if I disable "Transform Related Text Templates On Save" after this steps, then I can delete all .tt files... Can you reproduce this too?

    – kapsiR
    Mar 25 at 15:59











  • @katit It seems that it is enough to just remove the Custom Tool from the .edmx file

    – kapsiR
    Mar 25 at 16:14











  • Nope. If I remove Model1.tt - it will recreate both .tt files on "update". Yes, I have "Transform.." disabled

    – katit
    Mar 25 at 16:23













1





+150







1





+150



1




+150





If it's enough to have only the .edmx with two empty .tt files you can do that:



  1. Add the Entity Data Model (EF Designer from database)

  2. Cancel initial execution of the tools

  3. Empty Custom Tool value on each .tt file and on the .edmx file

  4. Delete contents of the .tt files if you want

  5. Delete .diagram file

After this steps, you can update your .edmx file and nothing happens.



Custom Tool emptyFinal solution






share|improve this answer













If it's enough to have only the .edmx with two empty .tt files you can do that:



  1. Add the Entity Data Model (EF Designer from database)

  2. Cancel initial execution of the tools

  3. Empty Custom Tool value on each .tt file and on the .edmx file

  4. Delete contents of the .tt files if you want

  5. Delete .diagram file

After this steps, you can update your .edmx file and nothing happens.



Custom Tool emptyFinal solution







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 25 at 15:43









kapsiRkapsiR

9371018




9371018












  • Looks like this is the best answer so far. You can ALSO delete .context.tt and it will "comply" with it. So, just Model1.tt required

    – katit
    Mar 25 at 15:52











  • The interesting part is, if I disable "Transform Related Text Templates On Save" after this steps, then I can delete all .tt files... Can you reproduce this too?

    – kapsiR
    Mar 25 at 15:59











  • @katit It seems that it is enough to just remove the Custom Tool from the .edmx file

    – kapsiR
    Mar 25 at 16:14











  • Nope. If I remove Model1.tt - it will recreate both .tt files on "update". Yes, I have "Transform.." disabled

    – katit
    Mar 25 at 16:23

















  • Looks like this is the best answer so far. You can ALSO delete .context.tt and it will "comply" with it. So, just Model1.tt required

    – katit
    Mar 25 at 15:52











  • The interesting part is, if I disable "Transform Related Text Templates On Save" after this steps, then I can delete all .tt files... Can you reproduce this too?

    – kapsiR
    Mar 25 at 15:59











  • @katit It seems that it is enough to just remove the Custom Tool from the .edmx file

    – kapsiR
    Mar 25 at 16:14











  • Nope. If I remove Model1.tt - it will recreate both .tt files on "update". Yes, I have "Transform.." disabled

    – katit
    Mar 25 at 16:23
















Looks like this is the best answer so far. You can ALSO delete .context.tt and it will "comply" with it. So, just Model1.tt required

– katit
Mar 25 at 15:52





Looks like this is the best answer so far. You can ALSO delete .context.tt and it will "comply" with it. So, just Model1.tt required

– katit
Mar 25 at 15:52













The interesting part is, if I disable "Transform Related Text Templates On Save" after this steps, then I can delete all .tt files... Can you reproduce this too?

– kapsiR
Mar 25 at 15:59





The interesting part is, if I disable "Transform Related Text Templates On Save" after this steps, then I can delete all .tt files... Can you reproduce this too?

– kapsiR
Mar 25 at 15:59













@katit It seems that it is enough to just remove the Custom Tool from the .edmx file

– kapsiR
Mar 25 at 16:14





@katit It seems that it is enough to just remove the Custom Tool from the .edmx file

– kapsiR
Mar 25 at 16:14













Nope. If I remove Model1.tt - it will recreate both .tt files on "update". Yes, I have "Transform.." disabled

– katit
Mar 25 at 16:23





Nope. If I remove Model1.tt - it will recreate both .tt files on "update". Yes, I have "Transform.." disabled

– katit
Mar 25 at 16:23













0














I'm not sure I understand fully, but I simply delete the pair of t4/tt files that are included with the model and the previously generated class files. They don't come back for EF6.



enter image description here



Then I delete them and I update model from database:



enter image description here



and they don't come back:



they don't come back



This is from EF 6.2:
enter image description here



Are you sure you're not dealing with some source control issue?






share|improve this answer

























  • We dont have Model1.Designer.cs and we don't have Model1.edmx.diagram. When we do "Update Model from Database" they come back. It's EF6.2

    – katit
    Mar 25 at 15:13











  • Using 6.2 also, the designer.cs file will get created but it's just got a comment: T4 code generation is enabled for model 'C:sourcereposConsoleApp2DataModel1.edmx'... Try adding a new model, repeat my steps to see...

    – reckface
    Mar 25 at 15:19











  • Just did that and it's restoring tts. I don't think it's source control because I can modify tts and then delete them after saving and it would restore with fresh unmodified tts. Also, when I do model I chose not to save connection string in .config and do the same on "update"

    – katit
    Mar 25 at 15:25











  • @katit it's actually impossible for .tt files to be regenerated. There's no mechanism in Visual Studio to recreate .tt files that are associated directly with the model. Tried this with EF5,even changing the Code Generation Strategy from T4, just creates db context

    – reckface
    Mar 25 at 16:50











  • Not sure what do you mean impossible. According to other posters and other answers - people are seeing same behaviour. If you delete .tt files and leave just .edmx - every time you "update" - VS/EF tool will recreate both .tt files.

    – katit
    Mar 25 at 16:52















0














I'm not sure I understand fully, but I simply delete the pair of t4/tt files that are included with the model and the previously generated class files. They don't come back for EF6.



enter image description here



Then I delete them and I update model from database:



enter image description here



and they don't come back:



they don't come back



This is from EF 6.2:
enter image description here



Are you sure you're not dealing with some source control issue?






share|improve this answer

























  • We dont have Model1.Designer.cs and we don't have Model1.edmx.diagram. When we do "Update Model from Database" they come back. It's EF6.2

    – katit
    Mar 25 at 15:13











  • Using 6.2 also, the designer.cs file will get created but it's just got a comment: T4 code generation is enabled for model 'C:sourcereposConsoleApp2DataModel1.edmx'... Try adding a new model, repeat my steps to see...

    – reckface
    Mar 25 at 15:19











  • Just did that and it's restoring tts. I don't think it's source control because I can modify tts and then delete them after saving and it would restore with fresh unmodified tts. Also, when I do model I chose not to save connection string in .config and do the same on "update"

    – katit
    Mar 25 at 15:25











  • @katit it's actually impossible for .tt files to be regenerated. There's no mechanism in Visual Studio to recreate .tt files that are associated directly with the model. Tried this with EF5,even changing the Code Generation Strategy from T4, just creates db context

    – reckface
    Mar 25 at 16:50











  • Not sure what do you mean impossible. According to other posters and other answers - people are seeing same behaviour. If you delete .tt files and leave just .edmx - every time you "update" - VS/EF tool will recreate both .tt files.

    – katit
    Mar 25 at 16:52













0












0








0







I'm not sure I understand fully, but I simply delete the pair of t4/tt files that are included with the model and the previously generated class files. They don't come back for EF6.



enter image description here



Then I delete them and I update model from database:



enter image description here



and they don't come back:



they don't come back



This is from EF 6.2:
enter image description here



Are you sure you're not dealing with some source control issue?






share|improve this answer















I'm not sure I understand fully, but I simply delete the pair of t4/tt files that are included with the model and the previously generated class files. They don't come back for EF6.



enter image description here



Then I delete them and I update model from database:



enter image description here



and they don't come back:



they don't come back



This is from EF 6.2:
enter image description here



Are you sure you're not dealing with some source control issue?







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 25 at 15:17

























answered Mar 25 at 15:04









reckfacereckface

3,42822546




3,42822546












  • We dont have Model1.Designer.cs and we don't have Model1.edmx.diagram. When we do "Update Model from Database" they come back. It's EF6.2

    – katit
    Mar 25 at 15:13











  • Using 6.2 also, the designer.cs file will get created but it's just got a comment: T4 code generation is enabled for model 'C:sourcereposConsoleApp2DataModel1.edmx'... Try adding a new model, repeat my steps to see...

    – reckface
    Mar 25 at 15:19











  • Just did that and it's restoring tts. I don't think it's source control because I can modify tts and then delete them after saving and it would restore with fresh unmodified tts. Also, when I do model I chose not to save connection string in .config and do the same on "update"

    – katit
    Mar 25 at 15:25











  • @katit it's actually impossible for .tt files to be regenerated. There's no mechanism in Visual Studio to recreate .tt files that are associated directly with the model. Tried this with EF5,even changing the Code Generation Strategy from T4, just creates db context

    – reckface
    Mar 25 at 16:50











  • Not sure what do you mean impossible. According to other posters and other answers - people are seeing same behaviour. If you delete .tt files and leave just .edmx - every time you "update" - VS/EF tool will recreate both .tt files.

    – katit
    Mar 25 at 16:52

















  • We dont have Model1.Designer.cs and we don't have Model1.edmx.diagram. When we do "Update Model from Database" they come back. It's EF6.2

    – katit
    Mar 25 at 15:13











  • Using 6.2 also, the designer.cs file will get created but it's just got a comment: T4 code generation is enabled for model 'C:sourcereposConsoleApp2DataModel1.edmx'... Try adding a new model, repeat my steps to see...

    – reckface
    Mar 25 at 15:19











  • Just did that and it's restoring tts. I don't think it's source control because I can modify tts and then delete them after saving and it would restore with fresh unmodified tts. Also, when I do model I chose not to save connection string in .config and do the same on "update"

    – katit
    Mar 25 at 15:25











  • @katit it's actually impossible for .tt files to be regenerated. There's no mechanism in Visual Studio to recreate .tt files that are associated directly with the model. Tried this with EF5,even changing the Code Generation Strategy from T4, just creates db context

    – reckface
    Mar 25 at 16:50











  • Not sure what do you mean impossible. According to other posters and other answers - people are seeing same behaviour. If you delete .tt files and leave just .edmx - every time you "update" - VS/EF tool will recreate both .tt files.

    – katit
    Mar 25 at 16:52
















We dont have Model1.Designer.cs and we don't have Model1.edmx.diagram. When we do "Update Model from Database" they come back. It's EF6.2

– katit
Mar 25 at 15:13





We dont have Model1.Designer.cs and we don't have Model1.edmx.diagram. When we do "Update Model from Database" they come back. It's EF6.2

– katit
Mar 25 at 15:13













Using 6.2 also, the designer.cs file will get created but it's just got a comment: T4 code generation is enabled for model 'C:sourcereposConsoleApp2DataModel1.edmx'... Try adding a new model, repeat my steps to see...

– reckface
Mar 25 at 15:19





Using 6.2 also, the designer.cs file will get created but it's just got a comment: T4 code generation is enabled for model 'C:sourcereposConsoleApp2DataModel1.edmx'... Try adding a new model, repeat my steps to see...

– reckface
Mar 25 at 15:19













Just did that and it's restoring tts. I don't think it's source control because I can modify tts and then delete them after saving and it would restore with fresh unmodified tts. Also, when I do model I chose not to save connection string in .config and do the same on "update"

– katit
Mar 25 at 15:25





Just did that and it's restoring tts. I don't think it's source control because I can modify tts and then delete them after saving and it would restore with fresh unmodified tts. Also, when I do model I chose not to save connection string in .config and do the same on "update"

– katit
Mar 25 at 15:25













@katit it's actually impossible for .tt files to be regenerated. There's no mechanism in Visual Studio to recreate .tt files that are associated directly with the model. Tried this with EF5,even changing the Code Generation Strategy from T4, just creates db context

– reckface
Mar 25 at 16:50





@katit it's actually impossible for .tt files to be regenerated. There's no mechanism in Visual Studio to recreate .tt files that are associated directly with the model. Tried this with EF5,even changing the Code Generation Strategy from T4, just creates db context

– reckface
Mar 25 at 16:50













Not sure what do you mean impossible. According to other posters and other answers - people are seeing same behaviour. If you delete .tt files and leave just .edmx - every time you "update" - VS/EF tool will recreate both .tt files.

– katit
Mar 25 at 16:52





Not sure what do you mean impossible. According to other posters and other answers - people are seeing same behaviour. If you delete .tt files and leave just .edmx - every time you "update" - VS/EF tool will recreate both .tt files.

– katit
Mar 25 at 16:52











0














You can try this.



  1. Delete .tt files under your .edmx file.

  2. Project -> Add -> New Item -> EF 6.x DbContext Generator

  3. It will generate new .tt files. In these .tt files you can specify .edmx file path.
    enter image description here


  4. Run these .tt files to generate Model1 classes.


  5. Disable .tt files (Don't delete content as you will need it if you want to update your entities later. Usually they generate new files when you save them)
    enter image description here


  6. Update your .edmx (add/remove tables).


  7. This will not generate new .tt files under edmx

  8. And it will not update your entity classes.

  9. And if you want to update your entity classes, then run .tt files.

enter image description here



I tried this and "Update Model From Database" didn't generate new .tt files. So hopefully your problem will be solved.






share|improve this answer

























  • It would be kind of workaround, however we have multiple .edmx files and having separate templates for each will be messy

    – katit
    Mar 25 at 15:54











  • We have this solution in our workspace. Usually we have all edmx in one project (lets say DataLayer) and all entities in another project (Entities). This makes a separation and allows flexibility. Also we have modified our .tt to generate some custom code (like interfaces for classes).

    – fhnaseer
    Mar 25 at 16:03











  • @katit but with this solution, the tt files will now generate any .cs files so your problem will be solved. In fact, I think it's pretty difficult for .tt files to be autogenerated.

    – reckface
    Mar 25 at 16:04











  • The good thing is that you don't delete anything. You just keep them separate and update each component whenever you want.

    – fhnaseer
    Mar 25 at 16:06















0














You can try this.



  1. Delete .tt files under your .edmx file.

  2. Project -> Add -> New Item -> EF 6.x DbContext Generator

  3. It will generate new .tt files. In these .tt files you can specify .edmx file path.
    enter image description here


  4. Run these .tt files to generate Model1 classes.


  5. Disable .tt files (Don't delete content as you will need it if you want to update your entities later. Usually they generate new files when you save them)
    enter image description here


  6. Update your .edmx (add/remove tables).


  7. This will not generate new .tt files under edmx

  8. And it will not update your entity classes.

  9. And if you want to update your entity classes, then run .tt files.

enter image description here



I tried this and "Update Model From Database" didn't generate new .tt files. So hopefully your problem will be solved.






share|improve this answer

























  • It would be kind of workaround, however we have multiple .edmx files and having separate templates for each will be messy

    – katit
    Mar 25 at 15:54











  • We have this solution in our workspace. Usually we have all edmx in one project (lets say DataLayer) and all entities in another project (Entities). This makes a separation and allows flexibility. Also we have modified our .tt to generate some custom code (like interfaces for classes).

    – fhnaseer
    Mar 25 at 16:03











  • @katit but with this solution, the tt files will now generate any .cs files so your problem will be solved. In fact, I think it's pretty difficult for .tt files to be autogenerated.

    – reckface
    Mar 25 at 16:04











  • The good thing is that you don't delete anything. You just keep them separate and update each component whenever you want.

    – fhnaseer
    Mar 25 at 16:06













0












0








0







You can try this.



  1. Delete .tt files under your .edmx file.

  2. Project -> Add -> New Item -> EF 6.x DbContext Generator

  3. It will generate new .tt files. In these .tt files you can specify .edmx file path.
    enter image description here


  4. Run these .tt files to generate Model1 classes.


  5. Disable .tt files (Don't delete content as you will need it if you want to update your entities later. Usually they generate new files when you save them)
    enter image description here


  6. Update your .edmx (add/remove tables).


  7. This will not generate new .tt files under edmx

  8. And it will not update your entity classes.

  9. And if you want to update your entity classes, then run .tt files.

enter image description here



I tried this and "Update Model From Database" didn't generate new .tt files. So hopefully your problem will be solved.






share|improve this answer















You can try this.



  1. Delete .tt files under your .edmx file.

  2. Project -> Add -> New Item -> EF 6.x DbContext Generator

  3. It will generate new .tt files. In these .tt files you can specify .edmx file path.
    enter image description here


  4. Run these .tt files to generate Model1 classes.


  5. Disable .tt files (Don't delete content as you will need it if you want to update your entities later. Usually they generate new files when you save them)
    enter image description here


  6. Update your .edmx (add/remove tables).


  7. This will not generate new .tt files under edmx

  8. And it will not update your entity classes.

  9. And if you want to update your entity classes, then run .tt files.

enter image description here



I tried this and "Update Model From Database" didn't generate new .tt files. So hopefully your problem will be solved.







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 25 at 15:49

























answered Mar 25 at 15:43









fhnaseerfhnaseer

3,94594289




3,94594289












  • It would be kind of workaround, however we have multiple .edmx files and having separate templates for each will be messy

    – katit
    Mar 25 at 15:54











  • We have this solution in our workspace. Usually we have all edmx in one project (lets say DataLayer) and all entities in another project (Entities). This makes a separation and allows flexibility. Also we have modified our .tt to generate some custom code (like interfaces for classes).

    – fhnaseer
    Mar 25 at 16:03











  • @katit but with this solution, the tt files will now generate any .cs files so your problem will be solved. In fact, I think it's pretty difficult for .tt files to be autogenerated.

    – reckface
    Mar 25 at 16:04











  • The good thing is that you don't delete anything. You just keep them separate and update each component whenever you want.

    – fhnaseer
    Mar 25 at 16:06

















  • It would be kind of workaround, however we have multiple .edmx files and having separate templates for each will be messy

    – katit
    Mar 25 at 15:54











  • We have this solution in our workspace. Usually we have all edmx in one project (lets say DataLayer) and all entities in another project (Entities). This makes a separation and allows flexibility. Also we have modified our .tt to generate some custom code (like interfaces for classes).

    – fhnaseer
    Mar 25 at 16:03











  • @katit but with this solution, the tt files will now generate any .cs files so your problem will be solved. In fact, I think it's pretty difficult for .tt files to be autogenerated.

    – reckface
    Mar 25 at 16:04











  • The good thing is that you don't delete anything. You just keep them separate and update each component whenever you want.

    – fhnaseer
    Mar 25 at 16:06
















It would be kind of workaround, however we have multiple .edmx files and having separate templates for each will be messy

– katit
Mar 25 at 15:54





It would be kind of workaround, however we have multiple .edmx files and having separate templates for each will be messy

– katit
Mar 25 at 15:54













We have this solution in our workspace. Usually we have all edmx in one project (lets say DataLayer) and all entities in another project (Entities). This makes a separation and allows flexibility. Also we have modified our .tt to generate some custom code (like interfaces for classes).

– fhnaseer
Mar 25 at 16:03





We have this solution in our workspace. Usually we have all edmx in one project (lets say DataLayer) and all entities in another project (Entities). This makes a separation and allows flexibility. Also we have modified our .tt to generate some custom code (like interfaces for classes).

– fhnaseer
Mar 25 at 16:03













@katit but with this solution, the tt files will now generate any .cs files so your problem will be solved. In fact, I think it's pretty difficult for .tt files to be autogenerated.

– reckface
Mar 25 at 16:04





@katit but with this solution, the tt files will now generate any .cs files so your problem will be solved. In fact, I think it's pretty difficult for .tt files to be autogenerated.

– reckface
Mar 25 at 16:04













The good thing is that you don't delete anything. You just keep them separate and update each component whenever you want.

– fhnaseer
Mar 25 at 16:06





The good thing is that you don't delete anything. You just keep them separate and update each component whenever you want.

– fhnaseer
Mar 25 at 16:06

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55288485%2fentity-framework-only-edmx-without-templates%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript