Quantcast
Channel: EntityFramework Reverse POCO Code First Generator
Viewing all 1642 articles
Browse latest View live

Commented Issue: Same stored procedure name on different schema generates only one method with duplicated parameters [180]

$
0
0
Let's say you have three stored procedure with the same name on different schema and one parameter:

```
Alpha.proc_DoSomething @Parameter datetime
Beta.proc_DoSomething @Parameter datetime
Omega.proc_DoSomething @Parameter datetime
```

Only one method is generated prepending the first schema name, and adding three parameters instead of one:

```
int Alpha_ProcDoSomething(System.DateTime? parameter, System.DateTime? parameter, System.DateTime? parameter);
```

Of course this won't compile, and you don't have all the methods you need.

Expected result:

```
int Alpha_ProcDoSomething(System.DateTime? parameter);

int Beta_ProcDoSomething(System.DateTime? parameter);

int Gamma_ProcDoSomething(System.DateTime? parameter);
```

I suspect the problem is on a query while retrieving the metadata.
Comments: Thanks. I'll get this fixed.

New Post: donation + some feature requests

$
0
0
point 5, issue 147 is now closed and released in 2.18

Edited Issue: Same stored procedure name on different schema generates only one method with duplicated parameters [180]

$
0
0
Let's say you have three stored procedure with the same name on different schema and one parameter:

```
Alpha.proc_DoSomething @Parameter datetime
Beta.proc_DoSomething @Parameter datetime
Omega.proc_DoSomething @Parameter datetime
```

Only one method is generated prepending the first schema name, and adding three parameters instead of one:

```
int Alpha_ProcDoSomething(System.DateTime? parameter, System.DateTime? parameter, System.DateTime? parameter);
```

Of course this won't compile, and you don't have all the methods you need.

Expected result:

```
int Alpha_ProcDoSomething(System.DateTime? parameter);

int Beta_ProcDoSomething(System.DateTime? parameter);

int Gamma_ProcDoSomething(System.DateTime? parameter);
```

I suspect the problem is on a query while retrieving the metadata.

Commented Issue: Same stored procedure name on different schema generates only one method with duplicated parameters [180]

$
0
0
Let's say you have three stored procedure with the same name on different schema and one parameter:

```
Alpha.proc_DoSomething @Parameter datetime
Beta.proc_DoSomething @Parameter datetime
Omega.proc_DoSomething @Parameter datetime
```

Only one method is generated prepending the first schema name, and adding three parameters instead of one:

```
int Alpha_ProcDoSomething(System.DateTime? parameter, System.DateTime? parameter, System.DateTime? parameter);
```

Of course this won't compile, and you don't have all the methods you need.

Expected result:

```
int Alpha_ProcDoSomething(System.DateTime? parameter);

int Beta_ProcDoSomething(System.DateTime? parameter);

int Gamma_ProcDoSomething(System.DateTime? parameter);
```

I suspect the problem is on a query while retrieving the metadata.
Comments: Thanks 0v3rCl0ck, this is now fixed and will be in the next release. ``` @@ -1907,9 +1907,10 @@ if(storedProcedureFilterExclude != null && storedProcedureFilterExclude.IsMatch(spName)) continue; - if (lastSp != spName || sp == null) + var fullname = schema + "." + spName; + if (lastSp != fullname || sp == null) { - lastSp = spName; + lastSp = fullname; sp = new StoredProcedure { IsTVF = isTVF, ```

Updated Wiki: Home

$
0
0

Due to errors on CodePlex which means I could no longer push/pull code changes. Namely:

  • HTTP Error: 500 (URL Rewrite Module Error.)
  • HTTP Error: 502 (Bad Gateway)

I have moved this project to GitHub: github.com/sjh37/efreversepoco

Updated Wiki: Documentation

$
0
0
Due to errors on CodePlex which means I could no longer push/pull code changes. Namely:
  • HTTP Error: 500 (URL Rewrite Module Error.)
  • HTTP Error: 502 (Bad Gateway)

I have moved this project to GitHub: https://github.com/sjh37/efreversepoco

Source code checked in, #1994e5e37f48

$
0
0
Include schema when checking stored procedure name

Commented Issue: Same stored procedure name on different schema generates only one method with duplicated parameters [180]

$
0
0
Let's say you have three stored procedure with the same name on different schema and one parameter:

```
Alpha.proc_DoSomething @Parameter datetime
Beta.proc_DoSomething @Parameter datetime
Omega.proc_DoSomething @Parameter datetime
```

Only one method is generated prepending the first schema name, and adding three parameters instead of one:

```
int Alpha_ProcDoSomething(System.DateTime? parameter, System.DateTime? parameter, System.DateTime? parameter);
```

Of course this won't compile, and you don't have all the methods you need.

Expected result:

```
int Alpha_ProcDoSomething(System.DateTime? parameter);

int Beta_ProcDoSomething(System.DateTime? parameter);

int Gamma_ProcDoSomething(System.DateTime? parameter);
```

I suspect the problem is on a query while retrieving the metadata.
Comments: Thank you!!

New Post: donation + some feature requests

Updated Wiki: Home

$
0
0

Due to errors on CodePlex which means I could no longer push/pull code changes. Namely:

  • HTTP Error: 500 (URL Rewrite Module Error.)
  • HTTP Error: 502 (Bad Gateway)

I have moved this project to GitHub: github.com/sjh37/efreversepoco

Updated Wiki: Home

Closed Unassigned: ForeignKeyExclude option [171]

$
0
0
We have some foreign keys that only meant for the database and are not meant to be used to traverse to a table. I have modified the "core.ttinclude" file to be able to take a regex to exclude.

``` c#
public override List<ForeignKey> ReadForeignKeys(Func<string, string, string> tableRename, Regex foreignKeyExclude)
{
var fkList = new List<ForeignKey>();
if(Cmd == null)
return fkList;

Cmd.CommandText = ForeignKeySQL + IncludeQueryTraceOn9481();
if (Cmd.GetType().Name == "SqlCeCommand")
Cmd.CommandText = ForeignKeySQLCE;
else
Cmd.CommandTimeout = 600;

using(DbDataReader rdr = Cmd.ExecuteReader())
{
while(rdr.Read())
{
string fkTableName = rdr["FK_Table"].ToString();
string fkSchema = rdr["fkSchema"].ToString();
string pkTableName = rdr["PK_Table"].ToString();
string pkSchema = rdr["pkSchema"].ToString();
string fkColumn = rdr["FK_Column"].ToString();
string pkColumn = rdr["PK_Column"].ToString();
string constraintName = rdr["Constraint_Name"].ToString();
int ordinal = (int) rdr["ORDINAL_POSITION"];

if (foreignKeyExclude.IsMatch(constraintName))
continue;

string fkTableNameFiltered = tableRename(fkTableName, fkSchema);
string pkTableNameFiltered = tableRename(pkTableName, pkSchema);

fkList.Add(new ForeignKey(fkTableName, fkSchema, pkTableName, pkSchema, fkColumn, pkColumn, constraintName, fkTableNameFiltered, pkTableNameFiltered, ordinal));
}
}

return fkList;

}
```

I also updated the parameters in the abstract class to account for the new parameter. So now when the "ReadForeignKeys" is called I pass in the "ForeignKeyExclude" to is created in the ".tt". I am not sure if anyone else would need this but I figured that I would at least put it out there.
Comments: Instead of a regex, I have simply used a boolean flag. Most people either want FKs or they don't. Filtering is quite tricky given the large, and sometimes generated FK names.

Commented Unassigned: ForeignKeyExclude option [171]

$
0
0
We have some foreign keys that only meant for the database and are not meant to be used to traverse to a table. I have modified the "core.ttinclude" file to be able to take a regex to exclude.

``` c#
public override List<ForeignKey> ReadForeignKeys(Func<string, string, string> tableRename, Regex foreignKeyExclude)
{
var fkList = new List<ForeignKey>();
if(Cmd == null)
return fkList;

Cmd.CommandText = ForeignKeySQL + IncludeQueryTraceOn9481();
if (Cmd.GetType().Name == "SqlCeCommand")
Cmd.CommandText = ForeignKeySQLCE;
else
Cmd.CommandTimeout = 600;

using(DbDataReader rdr = Cmd.ExecuteReader())
{
while(rdr.Read())
{
string fkTableName = rdr["FK_Table"].ToString();
string fkSchema = rdr["fkSchema"].ToString();
string pkTableName = rdr["PK_Table"].ToString();
string pkSchema = rdr["pkSchema"].ToString();
string fkColumn = rdr["FK_Column"].ToString();
string pkColumn = rdr["PK_Column"].ToString();
string constraintName = rdr["Constraint_Name"].ToString();
int ordinal = (int) rdr["ORDINAL_POSITION"];

if (foreignKeyExclude.IsMatch(constraintName))
continue;

string fkTableNameFiltered = tableRename(fkTableName, fkSchema);
string pkTableNameFiltered = tableRename(pkTableName, pkSchema);

fkList.Add(new ForeignKey(fkTableName, fkSchema, pkTableName, pkSchema, fkColumn, pkColumn, constraintName, fkTableNameFiltered, pkTableNameFiltered, ordinal));
}
}

return fkList;

}
```

I also updated the parameters in the abstract class to account for the new parameter. So now when the "ReadForeignKeys" is called I pass in the "ForeignKeyExclude" to is created in the ".tt". I am not sure if anyone else would need this but I figured that I would at least put it out there.
Comments: Instead of a regex, I have simply used a boolean flag. Most people either want FKs or they don't. Filtering is quite tricky given the large, and sometimes generated FK names.

Closed Unassigned: Filtering of "Navigation Properties" [157]

$
0
0
When building objects and thinking about DDD and aggregate boundaries, one often might choose to deliberately NOT have a full-on navigation property between aggregates, and only keep the ID of the related entity. It would be good to be able to filter the list of relationships that are generated using some sort of predicate filter.

I spoke with Simon who suggested that I could customise the EF.Reverse.POCO.Core.ttinclude file, searching for:

```
var fkList = reader.ReadForeignKeys(TableRename);
```
and filtering the values.

This is a suitable workaround, although obviously it would be preferable if the core ttinclude file simply referenced a `Func<ForeignKey>` defined somewhere in my .tt files. :)
Comments: Will be in the v2.19 being released later today

Closed Unassigned: Add ability to filter foreign keys [155]

$
0
0
Some users would like to filter out foreign keys.
This is necessary if the user moves some fields up into a base class by using WritePocoBaseClasses and UpdateColumn functions to set column.Hidden = true; on the columns pulled up into a base class.
Comments: Will be in the v2.19 being released later today

Closed Unassigned: Enum support [117]

$
0
0
Hi,
I create a patch for Enum support

Just add items to "Enums" Dictionary like this into main T4:

Enums.Add("dbo.TableName.FieldName","Namespace.Class.YourEnumType");

and use my attached file.

Comments: It already supports enums.

Closed Unassigned: Stored procedure with only one result set generates multiple resultsets class. [179]

$
0
0
First of all I'd like to say this POCO generator is a great tool. Really good job.
I'm using version 2.18.0 and I have found little bug.
I have stored procedure that returns only one resultset. It looks for example like this:

```
CREATE PROCEDURE [tst].[SP_Test]
@par int;

AS

BEGIN
IF (@par > 10000)
BEGIN
SELECT
UIC
, TITLE
FROM [tst].[SomeTbl1]
WHERE [TYPE] IN ('T1', 'T3')
ORDER BY HIERARCHY
END
ELSE BEGIN
SELECT
UIC
, TITLE
FROM [tst].[SomeTbl2]
WHERE [TYPE] IN ('T4', 'T5')
ORDER BY HIERARCHY
END
END
```

But generated class for this stored procedure looks like this:

```
public partial class SP_Test
{
public class ResultSetModel1
{
public System.String UIC { get; set; }
public System.String TITLE { get; set; }
}
public System.Collections.Generic.List<ResultSetModel1> ResultSet1;

public class ResultSetModel2
{
public System.String UIC { get; set; }
public System.String TITLE { get; set; }
}
public System.Collections.Generic.List<ResultSetModel2> ResultSet2;
}
```

I found some walkaround. I declare another table (@tbl) and make selection to this table.
At the end I make final selection right from this table.
It looks like this:

```
ALTER PROCEDURE [prrn].[prrn_get_Test]
@par int;

AS

BEGIN
DECLARE @tbl table (UIC int, TITLE nvarchar(500))

IF (@par > 10000)
BEGIN
INSERT INTO @tbl
SELECT
UIC
, TITLE
FROM [tst].[SomeTbl1]
WHERE [TYPE] IN ('T1', 'T3')
ORDER BY HIERARCHY
END
ELSE BEGIN
INSERT INTO @tbl
SELECT
UIC
, TITLE
FROM [tst].[SomeTbl2]
WHERE [TYPE] IN ('T4', 'T5')
ORDER BY HIERARCHY
END

SELECT *
FROM @tbl
END
```

And this walkaround generates class which is perfectly ok.
It looks like this:

```
public partial class SP_Test
{
public System.Int32? UIC { get; set; }
public System.String TITLE { get; set; }
}
```

But It's a little bit ugly, hacky way.
Comments: I won't be able to solve this because its SQL Server tells me there will be two result models. Change your result model to match and move the code to your project, so it won't be overwritten. Next, Override generation of return models for stored procedures that return entities. use StoredProcedureReturnTypes.Add("SpTest", "SpTestReturnModel");

New Post: Do we have NuGet package for it?

$
0
0
How do we upgrade POCO Generator?

Also, which version includes ability to exclude certain columns from models and where is it documented?

Thanks.

Created Unassigned: GenerateSeparateFiles causes empty DBContext class [181]

$
0
0
On version 2.19 if I set GenerateSeparateFiles=true; the DBContext class is empty except for the namespace. Setting it back to false will generate a complete DBContext class successfully.

I am able to reproduce this by adding a new item, selected Reverse POCO Generator, then just setting the connection string and GenerateSeparateFiles = true;

Created Unassigned: Many-to-many does not use proper naming [182]

$
0
0
It appears that in a many to many relationship, the first navigational property should be the plural without the foreign key and without "1" appended but in version 2.19 this does not happen.

For instance, we have the following tables:
* Roles
RoleId

* Permission
PermissionId

* RolePermission
RoleId
PermissionId

In the generated Role class, instead of a "Permissions" property in the reverse navigation , we get a property for "Permissions_PermissionId" and another for "Permissions1".

Similarly, in the generated Permission class we get properties "Roles_RoleId" and "Roles1".

It seems like the intention was to have a result where the Role class would have a property named "Permissions" and a second one named either "Permissions1" or "Permissions_PermissionId" - which would be fine if that was the result.

Viewing all 1642 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>