There seems problems about tt script generate MySQL model
See original GitHub issueI’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](IEnumerable
1 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:
- Created 8 years ago
- Comments:18 (7 by maintainers)
Top GitHub Comments
Hey it worked. Thank you so much 😃
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
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.