question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

There seems problems about tt script generate MySQL model

See original GitHub issue

I’ve installed MySQL 5.6 server on my Windows 7 OS. I use Visual Studio 2010 to develop software and download the linq2db from NuGet.

After I Installed the “LINQ to DB” , “LINQ to DB T4 Models” and “LINQ to MySql” , I copy the “CopyMe.MySql.tt.txt” to the Models folder(I develop an ASP.Net MVC project). Then I modify the file name to “CopyMe.MySql.tt” and modify the LoadMySqlMetadata method with correct data like below.

LoadMySqlMetadata(“localhost”, “world”, “root”, “mypassword”);

the “world” database is default generated by MySQL installer.

After I modify the LoadMySqlMetadata Method and saved the .tt script file.

It generate some error like below.


錯誤 1 正在執行轉換: System.InvalidOperationException: 序列未包含項目 於 System.Linq.Enumerable.Max(IEnumerable1 source) 於 System.Linq.Enumerable.Max[TSource](IEnumerable1 source, Func`2 selector) 於 Microsoft.VisualStudio.TextTemplating77DC7F2B06966E27F1DD4AC0DBECEEC6.GeneratedTextTransformation.GenerateTypesFromMetadata() 於 f:\VSProj\Linq2dbDemo\Linq2dbDemo\LinqToDB.Templates\LinqToDB.ttinclude: 行 205 於 Microsoft.VisualStudio.TextTemplating77DC7F2B06966E27F1DD4AC0DBECEEC6.GeneratedTextTransformation.<>c__DisplayClass1.<TransformText>b__0() 於 f:\VSProj\Linq2dbDemo\Linq2dbDemo\LinqToDB.Templates\DataModel.ttinclude: 行 11 於 Microsoft.VisualStudio.TextTemplating77DC7F2B06966E27F1DD4AC0DBECEEC6.GeneratedTextTransformation.GenerateModel() 於 f:\VSProj\Linq2dbDemo\Linq2dbDemo\LinqToDB.Templates\T4Model.ttinclude: 行 16 於 Microsoft.VisualStudio.TextTemplating77DC7F2B06966E27F1DD4AC0DBECEEC6.GeneratedTextTransformation.TransformText() 於 f:\VSProj\Linq2dbDemo\Linq2dbDemo\Models\CopyMe.MySql.tt: 行 42 於 Microsoft.VisualStudio.TextTemplating.TransformationRunner.RunTransformation(TemplateProcessingSession session, String source, ITextTemplatingEngineHost host, String& result) 1 1


If I change the parameter of LoadMySqlMetadata Method like below

LoadMySqlMetadata(“localhost”, “sakila”, “root”, “mypassword”);

the error message would be different like below


錯誤 1 正在執行轉換: System.Data.SqlTypes.SqlNullValueException: 資料為 Null。無法在值為 Null 的情況下呼叫這個方法或屬性。 於 MySql.Data.MySqlClient.MySqlDataReader.GetFieldValue(Int32 index, Boolean checkNull) 於 MySql.Data.MySqlClient.MySqlDataReader.GetString(Int32 i) 於 MySql.Data.MySqlClient.MySqlDataReader.GetString(String column) 於 MySql.Data.MySqlClient.SchemaProvider.GetIndexColumns(String[] restrictions) 於 MySql.Data.MySqlClient.SchemaProvider.GetSchemaInternal(String collection, String[] restrictions) 於 MySql.Data.MySqlClient.ISSchemaProvider.GetSchemaInternal(String collection, String[] restrictions) 於 MySql.Data.MySqlClient.SchemaProvider.GetSchema(String collection, String[] restrictions) 於 MySql.Data.MySqlClient.MySqlConnection.GetSchema(String collectionName, String[] restrictionValues) 於 MySql.Data.MySqlClient.MySqlConnection.GetSchema(String collectionName) 於 LinqToDB.DataProvider.MySql.MySqlSchemaProvider.GetPrimaryKeys(DataConnection dataConnection) 於 LinqToDB.SchemaProvider.SchemaProviderBase.GetSchema(DataConnection dataConnection, GetSchemaOptions options) 於 Microsoft.VisualStudio.TextTemplatingD168C78C55D712AF43FE7C599FEF2E64.GeneratedTextTransformation.LoadServerMetadata(DataConnection dataConnection) 於 f:\VSProj\Linq2dbDemo\Linq2dbDemo\LinqToDB.Templates\DataModel.ttinclude: 行 56 於 Microsoft.VisualStudio.TextTemplatingD168C78C55D712AF43FE7C599FEF2E64.GeneratedTextTransformation.LoadMetadata(DataConnection dataConnection) 於 f:\VSProj\Linq2dbDemo\Linq2dbDemo\LinqToDB.Templates\DataModel.ttinclude: 行 284 於 Microsoft.VisualStudio.TextTemplatingD168C78C55D712AF43FE7C599FEF2E64.GeneratedTextTransformation.LoadMySqlMetadata(String server, String database, String uid, String password) 於 f:\VSProj\Linq2dbDemo\Linq2dbDemo\LinqToDB.Templates\LinqToDB.MySql.ttinclude: 行 28 於 Microsoft.VisualStudio.TextTemplatingD168C78C55D712AF43FE7C599FEF2E64.GeneratedTextTransformation.TransformText() 於 f:\VSProj\Linq2dbDemo\Linq2dbDemo\Models\CopyMe.MySql.tt: 行 42 於 Microsoft.VisualStudio.TextTemplating.TransformationRunner.RunTransformation(TemplateProcessingSession session, String source, ITextTemplatingEngineHost host, String& result) 1 1


Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:18 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
shubham6396commented, Nov 21, 2018

Once more: you get this error during load of procedures schema due to missing information_schema.parameters view, which was added in MySQL 5.5.3. If you have lower version, you just need to disable procedures load using

GetSchemaOptions.GetProcedures = false;

If you don’t see any tables after that, it means that your schema filter is not correct (GetSchemaOptions.IncludedSchemas) - remove it and then add proper filter later if it generates tables from unwanted schemas.

Hey it worked. Thank you so much 😃

0reactions
MaceWinducommented, Nov 21, 2018

Once more: you get this error during load of procedures schema due to missing information_schema.parameters view, which was added in MySQL 5.5.3. If you have lower version, you just need to disable procedures load using

GetSchemaOptions.GetProcedures = false;

If you don’t see any tables after that, it means that your schema filter is not correct (GetSchemaOptions.IncludedSchemas) - remove it and then add proper filter later if it generates tables from unwanted schemas.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error while trying to generate MySQL Database from EF ...
I've setup a connection properly and can connect to it through my Server Explorer. Also the settings in the model seem correct: T4...
Read more >
Generate database from simple model fails in Visual Studio ...
Workaround: The problem seems to be the model.edmx file has a a wrong ... Make sure it's teh FIRST entry in connectionStrings. b)...
Read more >
70653: Error generate DDL script
Description: Hi, I use WINDOWS 8 MySql Connector Net 6.7.4 MySql Server 5.6 Visual studio 2012 EF5 Scrip to generate the database I...
Read more >
MySQL Bugs: #79840: SSH Tunnel queries hang
When running large queries over an SSH tunnel, mysql workbench hangs ... use test; CREATE TABLE tt (mycol varchar(1024) DEFAULT NULL) ...
Read more >
MySQL for Visual Studio :: 5.2 Code Editors
Right-click the connection, select New MySQL Script, and then select the language of the editor (JavaScript or Python) to open a new MySQL...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found