EntityFramework does not generate C # files (some enumerations are incomplete, so assembly fails)

At work, I just installed a completely new copy of my OS and a new copy of VS2015. When I first clone my solution, I can no longer create it, even if I created the C # files, as I always do, by opening the .edmx file first and clicking the "Save" icon.

When building, it throws an error:

CS0150: constant value expected

Because the listings that he generated are incomplete! Example:

public enum DocumentType : int { Identity = 1, ResidenceProof = 2, RegisterDoc = , } 

I also had this compiler error at the time, but after fixing it, my C # census files are still not generated correctly:

The ADO.NET provider with the invariant name "MySql.Data.MySqlClient" is either not registered in the machine or application configuration file, or cannot be loaded. See Internal Exception for more details.

How the hell should I fix this problem?

+7
c # entity-framework auto-generate
source share
2 answers

I had the same problem. It turned out that texttransform.exe could not understand the different line endings. My .tt file was saved using Unix EOL, and when I saved it using Windows EOL, it started working correctly. Just so simple - open your .tt file in WordPad and save.

+1
source share

Not quite the answer, but I will post my findings and the workaround I chose to use;

The T4 code generation template (the file attached to your .edmx file with the extension .tt file) contains code for generating C # using the data available in your model, I suspect the code in line # 204 (may be located on a different number lines in your version) to contain a minor error.

Screenshot of my active project and solution developer: Code inside .tt file

This line causes erroneous enumerations:

  this.GenerationEnvironment.Remove(this.GenerationEnvironment.Length - 3, 1); 

This presumably removes the generated code characters that were added by the enum generator to remove the last , from the listing, as this is not necessary.

I tested the functionality of this by adding output before this line, I tried to create an enumeration that would output MyEnumMemberName = TEST, and find that the output contained MyEnumMemberName = TES,

Using this, I found that changing the string to:

  this.GenerationEnvironment.Remove(this.GenerationEnvironment.Length - 2, 1); 

solves my problem.

It is currently not possible to check if this works on machines that already generate the correct code, but I hope this helps some of you. Good luck.

+1
source share

All Articles