-
-
Notifications
You must be signed in to change notification settings - Fork 66
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 scaffolding support [DNET798] #735
Comments
Modified by: @cincuranetFix Version: 6.post [ 10857 ] |
Commented by: Henning Hassmann (henning) Is there anything new on Scaffold? I can start it, but no database classes are created. |
Commented by: @cincuranet Nothing new. |
Modified by: @cincuranet |
Commented by: Vince (ramdevteam) Hello, I have the same pb. Before trying with my customer database , I have create a database with one table for testing. CREATE TABLE TESTITEM ( IDTABLE INTEGER NOT NULL, LIB VARCHAR(255)); Scaffold-dbcontext "User=SYSDBA;Password=masterkey;Database=D:\Projects\WebAppt\data\testcore.7data;DataSource=127.0.0.1;Port=3050;Dialect=3;Charset=NONE;Role=;Connection lifetime=15;Pooling=true;MinPoolSize=0;MaxPoolSize=50;PacketSize=8192;ServerType=0;" FirebirdSql.EntityFrameworkCore.Firebird -Output "D:\Projects\WebApp\testApp\Models\TestCore2" -Context "TestCore2" No database class are created. Juste a folder with TestCore2.cs with DbContext, override void OnConfiguring and override void OnModelCreating I missed something ? Thanks |
Commented by: @cincuranet You missed the ticket being still active... |
Modified by: @cincuranetFix Version: 6.planned [ 10857 ] => |
Commented by: Dejan Radic (dejan) This work for me Install-package EntityFrameworkCore.FirebirdSql -Version 2.1.2.2 Scaffold-DbContext "Server=myserver;Database=mydatabase;user id=SYSDBA;password=masterkey;" EntityFrameworkCore.FirebirdSql -Force -OutputDir Models and then downgrade to |
Commented by: Giacomo Policicchio (pgiacomo) Since i badly needed to scaffold an existing (big) db, I've made a branch with working Scaffolding. @jiri, I don't now if my work can be useful, because with this modification I needed to update several files, I know that the PR is cluttered with too many commits, if necessary I can cancel it and push a new branch with all modifications in one commit. thanks |
Commented by: @cincuranet I know about the PR (at least for 3.1) and I'm planning to merge it. The .NET 5 etc. changes are something that should be kept apart. At the moment I'm not sure how I'm going (if ever) to handle supporting EF Core 3.1 (because of LTS) and 5.0 that's latest. But that's something to think about when I have time and discuss it in the list. |
Commented by: Giacomo Policicchio (pgiacomo) EF Core in current master is targeted to run in Net 5.0, but compiled against netstandard2.0 API. I had errors running scaffolding when using EF Core with net 5.0, like methods not found, etc. So I recompiled using 5.0 APIs putting conditional defines in right places, remains one method related to annotations for wich there is no substitute, and for now I had no time to investigate it. So, for now the EF does not sense when a key shoud be made autoincremental. I'll see. |
Commented by: Marko P (projo94) After running this command: I am getting this error: Version of FirebirdSql.EntityFrameworkCore.Firebird is 7.10.1... Also tried with version 7.10.0, and getting the same error. |
Modified by: @cincuranetFix Version: vNext [ 10970 ] |
Can you please explain how to change the connection string to avoid setting Although It's in fact working with the WireCrypt = Enabled, But the data won't probably be encrypted with the current configuration. |
EntityFrameworkCore.FirebirdSql is not a package developed here. |
Alright, then can you please specify which certain EntityFrameworkCore version one should use with the latest version of FirebirdSQL.EntityFramework.Firebird to be able to Scaffold an existing DB? Which EFCore.Tools version should one also use with EFCore.Design? Is there a short version of the connection string where most of the parameters are set to a default value or identified at runtime? |
Use latest stable of FirebirdSql.EntityFrameworkCore.Firebird. The Microsoft.EntityFrameworkCore.Xxx packages should be from 5.x. Support for 6.x is not released yet (#1003).
In connection string you want to set at least database/server and username/password. Rest has sensible default values.
|
For the following set up:
scaffold-dbcontext returns "System.InvalidOperationException: Sequence contains no matching element". There's no 2.5 and lower version support for now, right? |
Scaffolding currently only works with EF Core 5. Any updates on scaffolding support for EF Core 6 @cincuranet ? |
Hello, I have following and try to scaffold ...
And, I can't get any information from the logs about the exact table(s) where the error occurred. What can I do now? Thanks! |
@Kaster, I ended up using FirebirdSql.Data.FirebirdClient, Version=8.0.1.0 without scaffolding. public static int ExecuteFirebirdProcedure(Action<string> log)
{
try
{
string conString = "character set=WIN1251;data source=127.0.0.1;initial catalog=database_name;user " +
"id=SYSDBA;password=masterkey;no garbage collect=true;role name = R201; max pool size" +
"=1000";
using (FbConnection FBCon = new FbConnection(conString))
{
FBCon.Open();
string param1 = "10.5", param2 = "5.1", param3 = "1.2";
FbCommand cmd =
new FbCommand($"execute procedure SP$STORED_PROCEDURE('{param1}', '{param2}', '{param3}');", FBCon);
int res = cmd.ExecuteNonQuery();
FBCon.Close();
return res;
}
}
catch (Exception ex)
{
log?.Invoke($"{nameof(ExecuteFirebirdProcedure)}: {ex.ToString()}. {ex.Message}");
return 0;
}
} Simple select statement will go through DataAdapter like this: using FirebirdSql.Data.FirebirdClient;
// your method to pull data from database to datatable
public void PullData(string query)
{ //character set=WIN1251;
string connString = @"data source=127.0.0.1;initial catalog=database_name;user id=SYSDBA;password=masterkey;no garbage collect=true;role name = R201; max pool size=1000";
if (string.IsNullOrEmpty(query))
{
_log.Invoke("Source query string was empty."); //query = "select * from CLIENTS";
return;
}
FbConnection conn = new FbConnection(connString);
conn.Open();
// create firebird command
FbCommand cmd = new FbCommand(query, conn);
// create data adapter
FbDataAdapter da = new FbDataAdapter(cmd);
// this will query your database and return the result to your datatable
dataTable = new DataTable();
da.Fill(dataTable);
// look for this method on stackoverflow if you need some XML table convertion
dataTable = XMLChanger.DataTableExtensions.GetNullFilledDataTableForXML(dataTable);
conn.Close();
da.Dispose();
} |
@sealkeen Thanks for the effort! I actually wanted to save myself this trip :-( I have more than 100 tables with an average of 30 columns each. In the meantime I have updated Firebird to 3.0 ... again there are errors with scaffolding:
But the classic way remains as an alternative. |
Open a new issue and provide the database structure. |
I actually had to deal with more than 1700 tables and 2300+ stored procedures within a single dialect 1 DB, which was larger than a single 220 GB file and I figured out that it's easier to learn SQL, PL/SQL rather than to scaffold it... The output from the database is handled by "for select *" within a stored procedure, returning the fields you need from the tables. And to input something it's just FBCommand ( ... ) ... "insert into tablename( fieldname1, fieldname2 ) values ( 1, 2 )" ... .ExecuteNonQuery(); From what I can tell you, scaffolding that DB resulted fine, except for around 20% of the tables missing (which I'm not exactly sure were) and 56 000 lines of DbContext code... |
Submitted by: @cincuranet
Jira_subtask_inward DNET663
Is duplicated by DNET886
Votes: 3
Commits: 88da531
The text was updated successfully, but these errors were encountered: