locked
Security Warning RRS feed

  • Question

  • User-419803913 posted

    So I have a very interesting issue that I could not find a solution to by simply Googling.  It started 2 days ago, where I updated my edmx file from the database (as I usual do) for a new column then received the following error: 

    Error 1 Running transformation: System.BadImageFormatException: Bad IL range.
       at System.Data.EntityModel.SchemaObjectModel.SchemaElementLookUpTable`1.KeyFromName(String unnormalizedKey)
       at System.Data.EntityModel.SchemaObjectModel.SchemaElementLookUpTable`1.KeyFromElement(T type)
       at System.Data.EntityModel.SchemaObjectModel.SchemaElementLookUpTable`1.TryAdd(T type)
       at System.Data.EntityModel.SchemaObjectModel.SchemaElementLookUpTable`1.Add(T type, Boolean doNotAddErrorForEmptyName, Func`2 duplicateKeyErrorFormat)
       at System.Data.EntityModel.SchemaObjectModel.Schema.TryAddType(SchemaType schemaType, Boolean doNotAddErrorForEmptyName)
       at System.Data.EntityModel.SchemaObjectModel.PrimitiveSchema..ctor(SchemaManager schemaManager)
       at System.Data.EntityModel.SchemaObjectModel.Schema.HandleAttributesComplete()
       at System.Data.EntityModel.SchemaObjectModel.SchemaElement.Parse(XmlReader reader)
       at System.Data.EntityModel.SchemaObjectModel.Schema.HandleTopLevelSchemaElement(XmlReader reader)
       at System.Data.EntityModel.SchemaObjectModel.Schema.InternalParse(XmlReader sourceReader, String sourceLocation)
       at System.Data.EntityModel.SchemaObjectModel.Schema.Parse(XmlReader sourceReader, String sourceLocation)
       at System.Data.EntityModel.SchemaObjectModel.SchemaManager.ParseAndValidate(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModel, AttributeValueNotification providerNotification, AttributeValueNotification providerManifestTokenNotification, ProviderManifestNeeded providerManifestNeeded, IList`1& schemaCollection)
       at System.Data.EntityModel.SchemaObjectModel.SchemaManager.ParseAndValidate(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModel, DbProviderManifest providerManifest, IList`1& schemaCollection)
       at System.Data.Metadata.Edm.EdmItemCollection.LoadItems(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModelOption, DbProviderManifest providerManifest, ItemCollection itemCollection, Boolean throwOnError)
       at System.Data.Metadata.Edm.EdmItemCollection.Init(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths, Boolean throwOnError)
       at System.Data.Metadata.Edm.EdmItemCollection..ctor(IEnumerable`1 xmlReaders, ReadOnlyCollection`1 filePaths, IList`1& errors)
       at Microsoft.VisualStudio.TextTemplating7F2E5A5930260F7871307ADC1AD37EDD3EC5FA455DC1AAD8564AF25AC467742D9BB9EBE57652DC511A0694845CEC0E6773CEEDED45E9109E11F94D327CF53537.GeneratedTextTransformation.EdmMetadataLoader.CreateEdmItemCollection(String sourcePath)
       at Microsoft.VisualStudio.TextTemplating7F2E5A5930260F7871307ADC1AD37EDD3EC5FA455DC1AAD8564AF25AC467742D9BB9EBE57652DC511A0694845CEC0E6773CEEDED45E9109E11F94D327CF53537.GeneratedTextTransformation.TransformText() C:\Users\750859\Documents\Visual Studio 2012\Projects\testingpart2\testingpart2\Models\ModelDB.tt 1 1 testingpart2

    Now, I have since created a new project and connected to my database using the Entity Framework and now get a Security Warning pop up message stating "Running this text template can potentially harm your computer.  Do not run it if you obtained it from an untrusted source." which is pointing to an internal db server.

    Any thoughts about this? 

    Thanks in advance.

    Wednesday, July 13, 2016 2:37 PM

Answers

  • User-2057865890 posted

    Hi Tonya410,

    Take a look at this thread. You could try following steps.

    1. Go where you project is located(open Solution explorer. right click on solution and click on "Open Folder in file explorer")
    2. Open EDMX file in editor and change ProviderManifestToken="2008". save it
    3. Build your solution

    Best Regards,

    Chris

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 26, 2016 2:56 AM

All replies

  • User-419803913 posted

    This article sounds related to my issue: Bad Image Format Exception when creating record in database

    I am planning to reinstall my Visual Studio applications.

    Wednesday, July 13, 2016 8:40 PM
  • User-2057865890 posted

    Hi Tonya410,

    I updated my edmx file from the database (as I usual do) for a new column

    To update the .edmx file when the database changes, in the Model Browser, right-click the .edmx file and select Update Model from Database.

    reference: http://www.asp.net/mvc/overview/getting-started/database-first-development/changing-the-database

    Error 1 Running transformation: System.BadImageFormatException: Bad IL range.

    There could be many and various reasons for this to happen: hardware failure, software bugs, but it shouldn't report "Bad IL range".

    Now, I have since created a new project and connected to my database using the Entity Framework and now get a Security Warning pop up message stating "Running this text template can potentially harm your computer.  Do not run it if you obtained it from an untrusted source." which is pointing to an internal db server.

    Any thoughts about this? 

    Any template published by Microsoft is safe to trust.

    Best Regards,

    Chris

    Thursday, July 14, 2016 6:52 AM
  • User-419803913 posted

    After a repair of Visual Studio 2013, all my database connections in previous code produced errors and when I attempted to complete an update from the database, I received the following error:

    An error occurred while connecting to the database.  The database might be unavailable.  An exception of type 'System.Data.Entity.Core.ProviderIncompatibleException' occurred. The message is: 'The provider did not return a ProviderManifest instance. The inner exception caught was of type 'System.BadImageFormatException', with the error message: 'Bad IL range.'.'.

    Any suggestions?

    Monday, July 18, 2016 1:30 PM
  • User-2057865890 posted

    Hi Tonya410,

    Take a look at this thread. You could try following steps.

    1. Go where you project is located(open Solution explorer. right click on solution and click on "Open Folder in file explorer")
    2. Open EDMX file in editor and change ProviderManifestToken="2008". save it
    3. Build your solution

    Best Regards,

    Chris

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 26, 2016 2:56 AM