Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EF Core 3 With Pomelo MySQL Provider Does Not Scaffold Views #867

Closed
hakankurcenlivivense opened this issue Oct 9, 2019 · 16 comments · Fixed by #896
Closed

EF Core 3 With Pomelo MySQL Provider Does Not Scaffold Views #867

hakankurcenlivivense opened this issue Oct 9, 2019 · 16 comments · Fixed by #896

Comments

@hakankurcenlivivense
Copy link

According to the following link, EF Core 3 supports reverse engineering views:
https://docs.microsoft.com/en-us/ef/core/what-is-new/ef-core-3.0/

And according to these links, there isn't yet a MySQL provider for EF Core 3:
dotnet/efcore#17556
https://dev.mysql.com/doc/connector-net/en/connector-net-entityframework-core.html

So, I used the Pomelo provider version 3.0.0-rc1.final to scaffold:

Scaffold-DbContext "server=server;user=user;password=password;database=database" "Pomelo.EntityFrameworkCore.MySql" -OutputDir EF -f

But scaffolding did not create the views. Are you also experiencing this issue or is this something related to my configuration?

@baronics
Copy link

baronics commented Oct 10, 2019

Just tried Pomelo provider version 3.0.0-rc1.final to scaffold my simple MySQL 8.0.17 database with 9 tables using .NET Core 3.0, VS2019 16.3.3 and it worked without any issues. I used the same Scaffold-DbContext command from the above comment. However, I have no views in my DB.

@MKI-Miro
Copy link

seem like my project is using mysql.data client even if i dont have reference to it anymore

at System.Data.Common.DbDataReader.GetFieldValue[T](Int32 ordinal) at MySql.Data.MySqlClient.MySqlDataReader.GetFieldValue[T](Int32 ordinal) in C:\projects\mysqlconnector\src\MySqlConnector\MySql.Data.MySqlClient\MySqlDataReader.cs:line 303 at Microsoft.EntityFrameworkCore.Query.RelationalShapedQueryCompilingExpressionVisitor.QueryingEnumerable1.Enumerator.MoveNext()
at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)

@baronics
Copy link

baronics commented Oct 10, 2019

My test project:
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>netcoreapp3.0</TargetFramework> </PropertyGroup> <ItemGroup> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.0.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> </PackageReference> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> </PackageReference> <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.0.0-rc1.final" /> </ItemGroup> </Project>

@bgrainger
Copy link
Collaborator

seem like my project is using mysql.data client even if i dont have reference to it anymore

at System.Data.Common.DbDataReader.GetFieldValue[T](Int32 ordinal) at MySql.Data.MySqlClient.MySqlDataReader.GetFieldValue[T](Int32 ordinal) in C:\projects\ mysqlconnector \src\ MySqlConnector \MySql.Data.MySqlClient\MySqlDataReader.cs:line 303 at

No, you are using the underlying MySqlConnector library.

@MKI-Miro

This comment has been minimized.

@baronics

This comment has been minimized.

@yukozh
Copy link
Member

yukozh commented Oct 10, 2019

https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/blob/master/src/EFCore.MySql/Scaffolding/Internal/MySqlDatabaseModelFactory.cs#L167-L174

Pomelo is using the information_schema to get the tables info, in this way, only real existed tables could be scaffolded, so the view is not working currently. And when I implement the scaffolding for Pomelo, the no key tables were not supported. Pomelo is a third party provider, it means some features are not aligned to the announcement which published by Microsoft. But we are going to align the features soon.

@MKI-Miro
Copy link

I dont have any view, I only have tables

@MKI-Miro

This comment has been minimized.

@yukozh

This comment has been minimized.

@MKI-Miro

This comment has been minimized.

@lauxjpn lauxjpn self-assigned this Oct 10, 2019
@lauxjpn lauxjpn added this to the 3.0.0 milestone Oct 10, 2019
@lauxjpn
Copy link
Collaborator

lauxjpn commented Oct 10, 2019

@hakankurcenlivivense Pomelo does support views in general. It seems though, that this has not yet been implemented for scaffolding an existing database, as the following SQL is used to query the tables only but not the views:

private const string GetTablesQuery = @"SHOW FULL TABLES WHERE TABLE_TYPE = 'BASE TABLE'";

I will implement this for 3.0.0-rc2 or do you want to do it @yukozh?

@lauxjpn
Copy link
Collaborator

lauxjpn commented Oct 10, 2019

@MKI-Miro, @baronics
Is your discussion actually related to the topic? If you are discussing a separate issue, please open a new one. Or are you discussing #866?

@MKI-Miro
Copy link

I am sory I thought I reply to #866

@lauxjpn
Copy link
Collaborator

lauxjpn commented Oct 10, 2019

@MKI-Miro No worries. I copied your discussion over to #866 as best as I could and will hide it in this issues here.

@lauxjpn
Copy link
Collaborator

lauxjpn commented Oct 27, 2019

Scaffolding views from existing databases has been added now with #896.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants