Closed airomero closed 4 years ago
@sjh37 Any word on the EFCore templates? Is version 3 even available?
I'll second @Phylum123 last question. Is v3 available anywhere? EFCore templates coming along?
Hi guys. Nearing the end of my family holiday so will be back home tomorrow. V3 is approx 95% complete and plan on releasing a beta within 2 weeks.
Here is a copy of the v3 code so far DropBox
Notes
Generator
project. Easy to edit and unit test.Generator
project and puts it into a single ttinclude file.Settings.Enumerations
in the database.tt file.Update: I now have stored procedures working, next are table valued functions, then I think that's it :-)
Hi @sjh37, could you refresh DropBox link because it has already expired?
@bartgaw Drop box link updated
It's a real shame stored procedures returning multiple results sets are yet supported by EF Core. They are not even in the plan for EF Core 3.0. For now, I'll leave a comment in the generated code saying as much. However, there is a part of me that wants to inject a little Dapper in there to support it, but if I went that route, I could do that for all stored procedures and table valued functions as they are not tracked in EF. For now, I'll keep it pure EF Core.
I have downloaded the files and decided to play with it. I have encountered some issues. I am trying to generate for EF core. Here are my settings:
Settings.DatabaseType = DatabaseType.SqlServer; // SqlServer, SqlCe. Coming next: PostgreSQL, MySql, Oracle
Settings.TemplateType = TemplateType.EfCore; // Ef6, EfCore, FileBased. FileBased specify folder using Settings.TemplateFolder
Settings.GeneratorType = GeneratorType.EfCore; // Ef6, EfCore, Custom. Custom edit GeneratorCustom class to provide your own implementation
Settings.UseMappingTables = false; // Set to false for EfCore. EFCore will add support for this in v3. If true, mapping will be used and no mapping tables will be generated. If false, all tables will be generated.
Settings.FileManagerType = FileManagerType.Custom; // VisualStudio = .NET project; Custom = .NET Core project; Null = No output (testing only)
Settings.ConnectionString = "Server=DEVMSCSQL1;Database=MHedgeWeb_Dev;Persist Security Info=True;User Id=MHedge_Dev;Password=Mh3dg3D0v!;";
Settings.ConnectionStringName = "MHedgeContext"; // ConnectionString key as specified in your app.config/web.config/appsettings.json
Settings.DbContextName = "MHedgeContext"; // Class name for the DbContext to be generated. Note: If generating separate files, please give the db context a different name from this tt filename.
Settings.GenerateSeparateFiles = true;
Settings.Namespace = DefaultNamespace; // Override the default namespace here
Settings.TemplateFolder = Path.Combine(Settings.Root, "Templates"); // Only used if Settings.TemplateType = TemplateType.FileBased; Please read https://github.com/sjh37/EntityFramework-Reverse-POCO-Code-First-Generator/wiki/Custom-file-based-templates
// If GenerateSingleDbContext = false, this will generate multiple db contexts. Please read https://github.com/sjh37/EntityFramework-Reverse-POCO-Code-First-Generator/wiki/Generating-multiple-database-contexts-in-a-single-go
Settings.GenerateSingleDbContext = true; // Set this to false to generate multiple db contexts.
Settings.MultiContextSettingsConnectionString = ""; // Leave empty to read data from same database in ConnectionString above. If settings are in another database, specify the connection string here.
// Elements to generate ***************************************************************************************************************
// Add the elements that should be generated when the template is executed.
// Multiple projects can be used that separate the different concerns.
// Settings.ElementsToGenerate = Elements.Poco | Elements.Context | Elements.Interface | Elements.PocoConfiguration | Elements.Enum;
Settings.ElementsToGenerate = Elements.Poco;
I am getting an error trying to generate the models:
// -----------------------------------------------------------------------------------------
// Failed to read database schema in LoadTables() - Invalid column name 'generated_always_type'. Invalid column name 'generated_always_type'.
/* at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader()
at Microsoft.VisualStudio.TextTemplatingEF9B480BBF279CC618DFC5736D3223817DF206489470A21678E4BF479E445EDE82BBCB4C2C50CA27E2246A2DF3CB7BADD40BF4DD0E4A864D2B562FFF31C910B1.GeneratedTextTransformation.DatabaseReader.ReadTables(Boolean includeSynonyms) in C:\Users\m34241\OneDrive - mcap.com\Documents\Source\CapitalMarkets\cm_mhedge_api\TestProject\Generated\EF.Reverse.POCO.v3.ttinclude:line 10134
at Microsoft.VisualStudio.TextTemplatingEF9B480BBF279CC618DFC5736D3223817DF206489470A21678E4BF479E445EDE82BBCB4C2C50CA27E2246A2DF3CB7BADD40BF4DD0E4A864D2B562FFF31C910B1.GeneratedTextTransformation.Generator.LoadTables() in C:\Users\m34241\OneDrive - mcap.com\Documents\Source\CapitalMarkets\cm_mhedge_api\TestProject\Generated\EF.Reverse.POCO.v3.ttinclude:line 3161*/
// -----------------------------------------------------------------------------------------
I figured out the issue. I can see in the older versions of reverse poco, you compensated for the lack of GeneratedAlwaysType, but not this version. Have you decided to only support SQL 2016 or later?
No, I missed a trick there, I also need to compensate. Thanks for helping to test.
I’ll give you a free 2 year licence when it goes live 😊
Here is the solution:
var temporalTableSupport = DatabaseProductMajorVersion >= 13;
if (!temporalTableSupport)
{
// Replace the column names (only present in SQL Server 2016 or later) with literal constants so the query works with older versions of SQL Server.
cmd.CommandText = cmd.CommandText
.Replace("[sc].[generated_always_type]", "0" )
.Replace("[c].[generated_always_type]", "0" )
.Replace("[st].[temporal_type]", "0" );
}
I stole most of it from the old version. If you place this in the ReadTables method, right below this chunk of code:
if (includeSynonyms && Settings.DatabaseType != DatabaseType.SqlCe) cmd.CommandText = SynonymTableSQLSetup() + TableSQL() + SynonymTableSQL() + SpecialQueryFlags(); else cmd.CommandText = TableSQL() + SpecialQueryFlags();
It will work. Thanks for the license :)
Here are the issues I have found so far using the generator with EF CORE:
Regardless of telling it to NOT generate configuration, it references the config files in the context when generated. EX:
modelBuilder.Configurations.Add(new ActiveDealConfiguration());
modelBuilder.Configurations.Add(new AdminHedgeSettingConfiguration());
modelBuilder.Configurations.Add(new AdminInputRangeConfiguration());
modelBuilder.Configurations.Add(new AdminRenewalOffsetConfiguration());
Are these required now?
In OnModelCreating this line of code generates an error: modelBuilder.Conventions.Add(new CodeFirstStoreFunctions.FunctionsConvention
Error on TransactionalBehaviour in stored procs, ex: Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, "EXEC @procResult = [dbo].[usp_CopyInvestorCriteria] ", procResultParam);
Provide an option to NOT generate Stored Procs and Functions
As you know table valued functions create an issue too.
Missing using statements: using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.Infrastructure; using System.Data.SqlClient;
Enums generate just fine. The only issue I have is that the code doesn't use them by default. After reading about it, a good approach would be to use the built in value converter
public enum EnumTableEnum
{
Opt1 = 0,
Opt2 = 1,
}
// -----------------
public class TestEntity
{
[Column("EnumTableId")]
public EnumTableEnum EnumTableEnum { get; set; }
}
// -----------------
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder
.Entity<TestEntity>()
.Property(e => e.EnumTableEnum)
.HasConversion(
v => (int)v,
v => (EnumTableEnum)v;
}
And then also have an option to store enums as strings:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder
.Entity<TestEntity>()
.Property(e => e.EnumTableEnum)
.HasConversion(
v => v.ToString(),
v => (EnumTableEnum)Enum.Parse(typeof(EnumTableEnum), v));
}
Is this something you would consider?
I found the EnumDefinitions... very similar to what I said above, except it seems EF CORE handles enum to int itself. The code in the last post should still be valid for storing enums as strings though. I have a suggestion for EnumDefinitions though, that I require myself and maybe others will find it useful.
Several of my enums are used in many tables. Listing out all of the tables where it is used is very cumbersome. Since I keep my Column name the same in every table (DealTypeId), I added code that says if it encounters a * in the table name, it doesn't matter what table the column is found in, it gets converted to the enum. Example Below:
public List<EnumDefinition> EnumDefinitions = new List<EnumDefinition>()
{
new EnumDefinition()
{
Schema = "dbo",
Table = "*",
Column = "DealTypeId",
EnumType = "DealTypeEnum"
}
};
And then I altered the UpdateColumn code that gets the definition to this:
// Perform Enum property type replacement
var enumDefinition = EnumDefinitions.FirstOrDefault
(e =>
(e.Schema.Equals(table.Schema.DbName, StringComparison.InvariantCultureIgnoreCase)) &&
(e.Table == "*" || e.Table.Equals(table.DbName, StringComparison.InvariantCultureIgnoreCase) ||
e.Table.Equals(table.NameHumanCase, StringComparison.InvariantCultureIgnoreCase)) &&
(e.Column.Equals(column.DbName, StringComparison.InvariantCultureIgnoreCase) ||
e.Column.Equals(column.NameHumanCase, StringComparison.InvariantCultureIgnoreCase))
);
Note: I just simply added (e.Table == "*" || ...
This allows the enum to be universal in your app and to not have to write down every table you use it on. This also shouldn't interfere with any intended functionality.
@Phylum123
e.Table == "*"
has been added to v2 and v3 code, good idea.FilterSettings.IncludeStoredProcedures = false;
In v2 return false from Settings.StoredProcedureFilter = (StoredProcedure sp) =>
function.HasConversion
. I'll take a look at this after table valued functions are complete.
Thanks again for your help.@Phylum123 For setting FilterSettings.IncludeStoredProcedures = false;
This is commented out in the Database.tt
file approx line 51.
Hi
Question below already answered. Please ignore! Line 87 in Database.tt file
Inflector.PluralisationService = new EnglishPluralizationService();
needed commenting out
Makes sense for my questions for V3 to be in the correct forum. Apologies for entering them in Q&A of the main feed.
Please may I request that the default settings make no changes to table names? I'm really struggling to stop all my table names being changed. Have tried various methods.
I thought these settings would stop any table renaming altogether as seemd to be the case in the past. Or the Inflector.PluralisationService one anyway.
Settings.GenerateSingleDbContext = true;
Inflector.PluralisationService = null;
But even if I try altering line 476 to
public override string TableRename(string name, string schema, bool isView)
{
return name;
}
which only removes comments anyway, would be sure to make the table rename just pass back an unchanged name?
I am dedicating the next few days to this solid. After using it for a few years I love it. Determined to be using V3 when it ships fully.
Hi Another heads up. I'm sure you will be aware of this on some level, but I'll raise it anyway. In Core 3.0 I had to change the following (output) code from
var procResultData = Query<exsp_PSDT_Planner_Results_Kiosk2ReturnModel>()
.FromSql(sqlCommand, typeParam, startDateParam, endDateParam, procResultParam)
.ToList();
to
var procResultData = Set<exsp_PSDT_Planner_Results_Kiosk2ReturnModel>()
.FromSqlRaw(sqlCommand, typeParam, startDateParam, endDateParam, procResultParam)
.ToList();
in order to fix the following warning and error reported in VS 2019 Preview.
Warning CS0618 'DbContext.Query
Error CS0619 'RelationalQueryableExtensions.FromSql
Not sure if I did the right thing here, but I thought I would run it by you.
@brillious Thanks, I've been testing with Core 2. Core 3 is still in preview, but good to know they've changed stuff important to the generated code.
I've updated code to include EfCore2, EfCore3 setting. This will cater for differences in code. Updated dropbox
Cheers. That was very fast.
After applying the following setting
Settings.TemplateType = TemplateType.EfCore3;
I still get the following code produced
public List<exsp_IDHReturnModel> exsp_IDH(int? documentID, out int procResult)
{
var documentIDParam = new SqlParameter { ParameterName = "@DocumentID", SqlDbType = SqlDbType.Int, Direction = ParameterDirection.Input, Value = documentID.GetValueOrDefault(), Precision = 10, Scale = 0 };
if (!documentID.HasValue)
documentIDParam.Value = DBNull.Value;
var procResultParam = new SqlParameter { ParameterName = "@procResult", SqlDbType = SqlDbType.Int, Direction = ParameterDirection.Output };
const string sqlCommand = "EXEC @procResult = [dbo].[exsp_IDH] @DocumentID";
var procResultData = Query<exsp_IDHReturnModel>()
.FromSql(sqlCommand, documentIDParam, procResultParam)
.ToList();
procResult = (int) procResultParam.Value;
return procResultData;
}
A quick alteration in a couple of places from
var procResultData = Query<{{ReturnModelName}}>(){{#newline}}
.FromSql(sqlCommand{{WriteStoredProcFunctionSqlParameterAnonymousArrayTrue}}){{#newline}}
To
var procResultData = {{QueryString}}<{{ReturnModelName}}>(){{#newline}}
.{{FromSql}}(sqlCommand{{WriteStoredProcFunctionSqlParameterAnonymousArrayTrue}}){{#newline}}
Seems to have done the trick.
Lines circa... 15630, 15631, 15663, 15664
@sjh37 I've tested the latest version and I've found a couple of bugs:
GenerateSeparateFiles = true
freezes the entire Visual Studio (both 2017 and 2019 latest versions). When I restart VS, I can see that files are correctly generated so this should be a simple bug. I've also tried administrator privileges, but to no avail. I've used default settings except TemplateType = TemplateType.EfCore2
, GeneratorType = GeneratorType.EfCore
and UseMappingTables = false
.ConnectionString
property using backslashes e.g. (localdb)\\mssqllocaldb
then the UseSqlServer
phrase in OnConfiguring
method contains a formatted string i.e. (localdb)\mssqllocaldb
.ConnectionStringName
property has been already implemented?Another heads up regards Core 3. Is a warning only, not an error.
'ModelBuilder.Query<TQuery>()' is obsolete: 'Use Entity<TEntity>().HasNoKey() instead'
In my code, altering
modelBuilder.Query<exsp_IDHReturnModel>();
To
modelBuilder.Entity<exsp_IDHReturnModel>().HasNoKey();
Seems to make the warning go away.
More heads up regards Core 3. Is a warning only, not an error.
Warning CS0618 'RelationalDatabaseFacadeExtensions.ExecuteSqlCommand(DatabaseFacade, RawSqlString, params object[])' is obsolete: 'For the execution of SQL queries using plain strings, use ExecuteSqlRaw instead. For the execution of SQL queries using interpolated string syntax to create parameters, use ExecuteSqlInterpolated instead.'
In my code, altering
Database.ExecuteSqlCommand("EXEC @procResult = [dbo].[exsp_Doc_Update] @Focus", focusParam, procResultParam);
To
Database.ExecuteSqlRaw("EXEC @procResult = [dbo].[exsp_Doc_Update] @Focus", focusParam, procResultParam);
Seems to make the warning go away.
Some more heads up agaian regards Core 3. Is a warning only, not an error.
Warning CS0618 'SqlServerPropertyBuilderExtensions.UseSqlServerIdentityColumn<TProperty>(PropertyBuilder<TProperty>, int, int)' is obsolete: 'Use ForSqlServerUseIdentityColumn instead'
In my code, altering...
builder.Property(x => x.ex_Action_History_ID).HasColumnName(@"ex_Action_History_ID").HasColumnType("int").IsRequired().ValueGeneratedOnAdd().UseSqlServerIdentityColumn();
To
builder.Property(x => x.ex_Action_History_ID).HasColumnName(@"ex_Action_History_ID").HasColumnType("int").IsRequired().ValueGeneratedOnAdd().ForSqlServerUseIdentityColumn();
Seems to make the warning go away.
Again, another warning only, but I hope it helps you.
I get this warning
'DbQuery<TQuery>' is obsolete: 'Use DbSet<T> instead'
Where this line of code is generated.
DbQuery<TQuery> Query<TQuery>() where TQuery : class;
I changed to
DbSet<TQuery> Query<TQuery>() where TQuery : class;
That seemed to do the trick. However, it does seem to be related to another error I have, though I'm not entirely sure myself. I have a DBContext of EntitiesDB. So...
public class EntitiesDB : DbContext, IEntitiesDB
Shows an error at IEntitiesDB
Error CS0738 'EntitiesDB' does not implement interface member 'IEntitiesDB.Query<TQuery>()'. 'DbContext.Query<TQuery>()' cannot implement 'IEntitiesDB.Query<TQuery>()' because it does not have the matching return type of 'DbSet<TQuery>'.
Removing the line
//DbSet<TQuery> Query<TQuery>() where TQuery : class;
entirely seems to fix, but I'm sure I am off course with this one?
@bartgaw
Setting
GenerateSeparateFiles = true
freezes the entire Visual Studio (both 2017 and 2019 latest versions). When I restart VS, I can see that files are correctly generated so this should be a simple bug.
I too have experienced VS2019 hanging and never appears to complete, just get a little spinner, which in the end I have to force shut VS2019 and restart. I am pleased to report that it has been fixed in Visual Studio 2019 v16.1.5 It should not happen in VS2017 at all? What Visual Studio versions do you have
VS Professional 2017 (15.9.14) and Professional 2019 (16.1.6).
EDIT: I updated VS 2019 to 16.2.0 but I still encounter this issue.
@bartgaw
It does not seem that ConnectionStringName property has been already implemented?
I no longer search for connections strings in the config files within the solution as the generator can be in a .net core project, hence the reason for the Settings.ConnectionString
.
The Settings.ConnectionStringName
is still required for the templates, to place the name of the connection within the generated code.
Settings.ConnectionStringName = "Reporting";
...
// EF6 Ctor
public MyDbContext()
: base("Name=Reporting") // <<--- Settings.ConnectionStringName
{
}
Hey Simon, A couple more bugs for you.
In the EF Core template, in the context, you pass DbModelBuilder instead of ModelBuilder in the partial methods.
Please also remove or have an option to remove the empty constructor for the context, as it has issues with dependency injection on asp core projects. It requires that the context has only a single constructor with DbContextOptions.
I don't know if this is something related to your generator or to the VS Code add-in, but I'll report here in case it's something you might need to address.
I have a .NET core project and have successfully use the generator in Visual Studio 2019.
In VSCode, I have installed the extension:
https://marketplace.visualstudio.com/items?itemName=aisoftware.tt-processor
When I try to run the tt template in VSCode, I get the following error:
Error: Command failed: C:\"Program Files (x86)"\"Common Files"\"microsoft shared"\TextTemplating\14.0\TextTransform.exe "c:\Users\GregPetrites\source\repos\ConsoleApp4\ConsoleApp4\Database.tt"
c:\Users\GregPetrites\source\repos\ConsoleApp4\ConsoleApp4\EF.Reverse.POCO.v3.ttinclude(8,4) : error : There was an error loading the include file 'EF6.Utility.CS.ttinclude'. The transformation will not be run. The following Exception was thrown:
System.IO.FileNotFoundException: Could not find file 'c:\Users\GregPetrites\source\repos\ConsoleApp4\ConsoleApp4\EF6.Utility.CS.ttinclude'.
File name: 'c:\Users\GregPetrites\source\repos\ConsoleApp4\ConsoleApp4\EF6.Utility.CS.ttinclude'
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost)
at System.IO.StreamReader..ctor(String path)
at Microsoft.VisualStudio.TextTemplating.CommandLine.CommandLineHost.ReadFileContent(String fileName)
at Microsoft.VisualStudio.TextTemplating.CommandLine.CommandLineHost.LoadIncludeText(String requestFileName, String& content, String& location)
at Microsoft.VisualStudio.TextTemplating.Engine.ProcessIncludeDirective(Directive directive, ITextTemplatingEngineHost host, VisitedFiles includedFiles)
@GPetrites Hi Greg, I've never used or tested this extension in VS Code, however check that you have EF6.Utility.CS.ttinclude
installed. I have two locations:
Check your TT processor configuration so it can find that file on your system.
Hi Simon, is the EF core version available here in its current form? I have it working and although we are probably not using all of the features (just found IsMaxLength not implemented in EF Core!), what you have by now should be usable for most people. Should it be/is it another github project so people don't get confused between them? Thanks.
Hi @lukos it's almost there. I keep the dropbox link up to date each time I have all the tests passing.
Table valued functions are next on my todo list.
This repo will eventually be replaced with the full v3 source code, not just what's in the dropbox zip. I can't release the source code just yet as that will confuse people as the source code does not match the currently released v2 VSIX. Once ready, and I have the legals and website sorted and in place, then I can release the full source code in this repo :-)
Updated DropBox with latest code.
Main update was to EF.Core Foreign Keys which now make use of .HasPrincipalKey
.
Table valued functions are still pending, but the code should now be production ready.
Any beta testing feedback with the above dropbox link code would be greatefully received. Thanks, Simon.
Thanks for the latest update. Things progressing fast.
I know you aren't focused on Core v3 yet, but have also done some prep work for that. The only breaking code I have found is as follows.
In my output code I have a line...
DbQuery<TQuery> Query<TQuery>() where TQuery : class;
...causes the following error (where EntitiesDB is what I call my DBContext).
Severity Code Description Project File Line Suppression State
Error CS0738 'EntitiesDB' does not implement interface member 'IEntitiesDB.Query<TQuery>()'. 'DbContext.Query<TQuery>()' cannot implement 'IEntitiesDB.Query<TQuery>()' because it does not have the matching return type of 'DbQuery<TQuery>'.
I'm sure there is more to it, but I have found that simply removing that output line gets my code working again.
Reminder from previous comment regards an obsolete bit of code in Core v3 again. Warning only this one.
'ModelBuilder.Query
In my code, altering
modelBuilder.Query<exsp_IDHReturnModel>();
To
modelBuilder.Entity<exsp_IDHReturnModel>().HasNoKey();
Seems to make the warning go away.
Hey, do you happen to have settings available that will work with the dotnet ef dbcontext scaffold command line tool?
That's how I've been getting by, although the generated code has errors in some cases. It doesn't have any real options other than naming your context so I would think coming up with the settings would not be too hard... If you happen to have something like that I'm willing to help test. Or maybe I can create it since I suspect a lot of people must be using this.
The Dropbox link only contains the very basic ttinclude file. That file is actually generated from a separate C# project. This separate project will be included in this repository once I push the new version. I always had it in mind that once this is initially published, it would be straightforward to create a dotnet extension as it's already in a DLL, so just need to create some sort of settings JSON file and we're good to go. Not long now. Should be approx 4 weeks to have legals and new website put in place.
@brillious I've now got a .Net Core 3.0 version working against Microsoft.EntityFrameworkCore 3.0.0-preview8.19405.11 I've updated the DropBox link with the latest code :-)
Fantastic. Gonna look at this first thing tomorrow morning.
Thanks Simon.
Mark
On Thu, 29 Aug 2019, 19:48 Simon Hughes, notifications@github.com wrote:
@brillious https://github.com/brillious I've now got a .Net Core 3.0 version working against Microsoft.EntityFrameworkCore 3.0.0-preview8.19405.11 I've updated the DropBox https://www.dropbox.com/s/c8or3gfr9qokp8h/ReversePoco.7z?dl=0 link with the latest code :-)
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sjh37/EntityFramework-Reverse-POCO-Code-First-Generator/issues/5?email_source=notifications&email_token=AIMZILJXKIDHNBSJHA2WPW3QHAKX3A5CNFSM4B46YSSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5POTGQ#issuecomment-526313882, or mute the thread https://github.com/notifications/unsubscribe-auth/AIMZILJV665MVI4LMKMQCOLQHAKX3ANCNFSM4B46YSSA .
@brillious I've now got a .Net Core 3.0 version working against Microsoft.EntityFrameworkCore 3.0.0-preview8.19405.11 I've updated the DropBox link with the latest code :-)
Absolutely worked a treat first thing. No errors, no warnings. Brilliant stuff. I'm just waiting for a server upgrade from Windows Server 2008 Std to Windows Server 2019 for my web server, then I will be good to go with my Core 3 migration. It's been a long time in the wings, but I'm pretty happy with where this is right now.
I am trying it with the last .net core 3 preview 9.xxx, generation is fine without mapping tables (maybe next preview) and fakedbset file has some errors about ValueTask instead of Task easily resolved and one about IAsyncEnumerableAccessor is not available. Is it on any reference assembly or is out of .net core yet? Congrats Simon, very good work. Ah, and one error with the connection string about escape slash for example with "(local)\INSTANCENAME", I had to put two back slashes, but in generated file is only one and gives an error, so I had to write it one more again in generated code.
Thanks @fjrodriguezcom. EfCore2 will never support mapping tables. EfCore3 will, but just not yet, For now keep mapping tables turned off with:
Settings.UseMappingTables = false; // Set to false for EfCore.
// EFCore will add support for this in v3.
// If true, mapping will be used and no mapping tables will be generated.
// If false, all tables will be generated.
I'll take a look at the FakeDbSet errors for EfCore3.
Thanks for your help. Send me an email simon@hicrest.net
and I'll give you a free 1 year commercial lience as a thank you for your help.
Hey Simon, I'm testing your tool against EntityFramework Preview 8 and 9 and works fine. Only I was able to find two "bugs".
Settings.NameSpace The example you bring by default is writed without double quotes. If I write for example ConsoleApp5.Models it fails. I have to write "ConsoleApp4.Models"; Maybe you can write by default with double quotes and nobody will face my problem anymore.
Elements.Interface If you don't want to generate the interface, context doesn't care and tries to implement it anyways. I have to remove manually the code on my context.
Nothing more at this moment. Thank you for this great tool!
@fjrodriguezcom Updated generator in dropbox. Efcore3 now uses ValueTask, plus a few other Fake*
fixes.
@cgonzalezri Elements.Interface
if this is missed, the context will still use an interface. This is by design. This is because you can install the generator into different folders or even projects, and specify different things to generate. One project may be for interfaces, another project for the implementation, etc. If you miss-out the Elements.Interface
you must specify where it is with Settings.InterfaceNamespace
. The Settings.InterfaceNamespace
will simply add a using into the context code.
Hey, is there an updated dropbox link? The one above isn't working anymore. Was thinking of taking your code for a spin and seeing what I can break. :)
@sjh37 is there an ETA on release date?
Hi, is there any plan to support EF7? EF7 is more stable now and we love EFReversePoco, so it'd be so nice to start playing with both together. Thanks!!