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

Edited Issue: Column filter doesn't exclude full column names as I expect [167]

$
0
0
Hi,

I have a column called DateCreated in a table called Products.SupplierProduct - I don't want this attribute to show up in the POCO.

When I set the column filter to:

ColumnFilterExclude = new Regex("^Products.SupplierProduct.DateCreated$");

It still adds the column. But when I place the schema after the table name, like so:

ColumnFilterExclude = new Regex("^SupplierProduct.Products.DateCreated$");

It works.

Shouldn't it be [schema_name].[table_name].[column_name]?

Commented Issue: Column filter doesn't exclude full column names as I expect [167]

$
0
0
Hi,

I have a column called DateCreated in a table called Products.SupplierProduct - I don't want this attribute to show up in the POCO.

When I set the column filter to:

ColumnFilterExclude = new Regex("^Products.SupplierProduct.DateCreated$");

It still adds the column. But when I place the schema after the table name, like so:

ColumnFilterExclude = new Regex("^SupplierProduct.Products.DateCreated$");

It works.

Shouldn't it be [schema_name].[table_name].[column_name]?
Comments: Good find. The code did this ``` var fullName = string.Format("{0}.{1}.{2}", table.Name, table.Schema, col.Name); ``` I have now changed it to this ``` var fullName = string.Format("{0}.{1}.{2}", table.Schema, table.Name, col.Name); ``` See this [changeset](https://efreversepoco.codeplex.com/SourceControl/changeset/23656ea97117). This will be in the next release.

Commented 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: In the case of TPT (Table Per Type) I did well. What do you think? :) ``` // Use the following function if you need to apply additional modifications to a column // eg. normalise names etc. UpdateColumn = (Column column, Table table) => { // Example //if (column.NameHumanCase == "PkId") // column.NameHumanCase = "Id"; if (table.NameHumanCase=="tablename" && column.NameHumanCase=="id") { column.Hidden=true; } } ```

Commented Issue: Column filter doesn't exclude full column names as I expect [167]

$
0
0
Hi,

I have a column called DateCreated in a table called Products.SupplierProduct - I don't want this attribute to show up in the POCO.

When I set the column filter to:

ColumnFilterExclude = new Regex("^Products.SupplierProduct.DateCreated$");

It still adds the column. But when I place the schema after the table name, like so:

ColumnFilterExclude = new Regex("^SupplierProduct.Products.DateCreated$");

It works.

Shouldn't it be [schema_name].[table_name].[column_name]?
Comments: Thank you.

Source code checked in, #06dcf2cd2377

Source code checked in, #9609e1863455

Created Unassigned: PkTableHumanCase pluralize fail with SpanishPluralizationService [168]

$
0
0
Hi,

For example if the table name is "Invenfis" to use the service pluralization __SpanishPluralizationService__ it returns an empty string in the

```
foreignKey.PkTableHumanCase method (useCamelCase,prependSchemaName).
```


Attached image to check it.
![Image](https://onedrive.live.com/redir?resid=5A42A4A3C5F8974!84543&authkey=!AFTygq7iEThhG0o&v=3&ithint=photo%2cpng)

For now to solve my problem, what I do is evaluate the following expression:

```
string singular = Inflector.MakeSingular(PkTableNameFiltered);
if (string.IsNullOrEmpty(singular))
{
singular=PkTableNameFiltered;
};
```

![Image](https://onedrive.live.com/redir?resid=5A42A4A3C5F8974!84542&authkey=!AIzBUy05xGsudDE&v=3&ithint=photo%2cpng)

All edit in file _EF.Reverse.POCO.Core.ttinclude_


Thank you very much for getting my issue

Closed Unassigned: PkTableHumanCase pluralize fail with SpanishPluralizationService [168]

$
0
0
Hi,

For example if the table name is "Invenfis" to use the service pluralization __SpanishPluralizationService__ it returns an empty string in the

```
foreignKey.PkTableHumanCase method (useCamelCase,prependSchemaName).
```


Attached image to check it.
![Image](https://onedrive.live.com/redir?resid=5A42A4A3C5F8974!84543&authkey=!AFTygq7iEThhG0o&v=3&ithint=photo%2cpng)

For now to solve my problem, what I do is evaluate the following expression:

```
string singular = Inflector.MakeSingular(PkTableNameFiltered);
if (string.IsNullOrEmpty(singular))
{
singular=PkTableNameFiltered;
};
```

![Image](https://onedrive.live.com/redir?resid=5A42A4A3C5F8974!84542&authkey=!AIzBUy05xGsudDE&v=3&ithint=photo%2cpng)

All edit in file _EF.Reverse.POCO.Core.ttinclude_


Thank you very much for getting my issue

Comments: I did not write the Spanish pluralisation service. Try using a custom pluralisation entry for Invenfis to see if that helps. Sorry but there is nothing I can do.

Edited Issue: PkTableHumanCase pluralize fail with SpanishPluralizationService [168]

$
0
0
Hi,

For example if the table name is "Invenfis" to use the service pluralization __SpanishPluralizationService__ it returns an empty string in the

```
foreignKey.PkTableHumanCase method (useCamelCase,prependSchemaName).
```


Attached image to check it.
![Image](https://onedrive.live.com/redir?resid=5A42A4A3C5F8974!84543&authkey=!AFTygq7iEThhG0o&v=3&ithint=photo%2cpng)

For now to solve my problem, what I do is evaluate the following expression:

```
string singular = Inflector.MakeSingular(PkTableNameFiltered);
if (string.IsNullOrEmpty(singular))
{
singular=PkTableNameFiltered;
};
```

![Image](https://onedrive.live.com/redir?resid=5A42A4A3C5F8974!84542&authkey=!AIzBUy05xGsudDE&v=3&ithint=photo%2cpng)

All edit in file _EF.Reverse.POCO.Core.ttinclude_


Thank you very much for getting my issue

Created Unassigned: WCF does not mark add [DataContract] and [DataMember] to stored proc return model [169]

$
0
0
WCF flag does not add [DataContract] and [DataMember] to stored proc return model. I would be nice have the WCF flag also add these attributes to the stored procedure types.

Edited Unassigned: WCF does not mark add [DataContract] and [DataMember] to stored proc return model [169]

$
0
0
WCF flag does not add [DataContract] and [DataMember] to stored proc return model. It would be nice have the WCF flag also add these attributes to the stored procedure types.

Edited Unassigned: WCF flag does not add [DataContract] and [DataMember] to stored proc return model [169]

$
0
0
WCF flag does not add [DataContract] and [DataMember] to stored proc return model. It would be nice have the WCF flag also add these attributes to the stored procedure types.

Commented Issue: PkTableHumanCase pluralize fail with SpanishPluralizationService [168]

$
0
0
Hi,

For example if the table name is "Invenfis" to use the service pluralization __SpanishPluralizationService__ it returns an empty string in the

```
foreignKey.PkTableHumanCase method (useCamelCase,prependSchemaName).
```


Attached image to check it.
![Image](https://onedrive.live.com/redir?resid=5A42A4A3C5F8974!84543&authkey=!AFTygq7iEThhG0o&v=3&ithint=photo%2cpng)

For now to solve my problem, what I do is evaluate the following expression:

```
string singular = Inflector.MakeSingular(PkTableNameFiltered);
if (string.IsNullOrEmpty(singular))
{
singular=PkTableNameFiltered;
};
```

![Image](https://onedrive.live.com/redir?resid=5A42A4A3C5F8974!84542&authkey=!AIzBUy05xGsudDE&v=3&ithint=photo%2cpng)

All edit in file _EF.Reverse.POCO.Core.ttinclude_


Thank you very much for getting my issue

Comments: OK thank you very much Simon

Created Unassigned: Entity Configurations added in both OnModelCreating and CreateModel methods [170]

$
0
0
When I select the a generated class and context in the MVC5 controller dialog, I receive the following error:

```
There was an error running the selected code generator: 'A configuration for type 'Foo' has already been added. To reference the existing configuration use the Entity<T>() or ComplexType<T>() methods'
```

This seems to relate to the contents of the generated OnModelCreating and CreateModel methods both of which try and add each of the entity Configuration classes to the modelBuilder.Configurations collection.


Edited Feature: WCF flag does not add [DataContract] and [DataMember] to stored proc return model [169]

$
0
0
WCF flag does not add [DataContract] and [DataMember] to stored proc return model. It would be nice have the WCF flag also add these attributes to the stored procedure types.

Created 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.

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: Slight change to the code as I did not check for NULL. ``` c# if (foreignKeyExclude != null && foreignKeyExclude.IsMatch(constraintName)) continue; ```

New Post: Exclude schema tables, rename (hide schema prefix)

$
0
0
Hello, there are several schemas in my database - dbo, acc, cache, export.
I don't want to generate tables from acc and export schemas.

I have tryed:
SchemaName = null;
PrependSchemaName = true;
TableFilterExclude = new Regex("(export_.*)|(acc_.*)");
but it's doesn't work, generator generates acc and export tables.

Then I want to hide schema prefix for some tables.
For example cache_Customer, I want to rename to Customer.
TableRename = (name, schema) =>
{
    return name.Replace("cache_", "");
};
This code doen't work.
How to fix this configuration?

New Post: Exclude schema tables, rename (hide schema prefix)

$
0
0
The schema filter is a bit rubbish at the moment, and I plan on making into a regex, similar to TableFilterExclude/Include.
It should be trivial to implement it yourself.

Inside EF.Reverse.POCO.Core.ttinclude. At approx line 520 you will see this line
if(SchemaName != null && String.Compare(tables[i].Schema, SchemaName, StringComparison.OrdinalIgnoreCase) != 0)
Change it to a regex:
var SchemaRegex = new Regex("^dbo$|^cache$");
if(!SchemaRegex .IsMatch(tables[i].Name))
{
    tables.RemoveAt(i);
    continue;
}

Commented Unassigned: The generated context class still implements IDbContextName if unit of work is disabled [152]

$
0
0
If Elements.UnitOfWork is omitted from ElementsToGenerate, the generated context class still implements the interface, despite the interface not actually being generated.

I temporarily fixed this around line 190 in EF.Reverse.POCO.ttinclude by adding an if (ElementsToGenerate.HasFlag(Elements.UnitOfWork)) wrapper around the interface inclusion.
Comments: This is intentional, because you should add the generator to another folder or project, and specify the Elements.UnitOfWork there. For example: __Interfaces project,__ specifies Elements.UnitOfWork __Context project,__ specifies Elements.Context. Add a reference to the interfaces project. This way you always code against your interface, so you can swap out the real context for a fake one during unit testing.
Viewing all 1642 articles
Browse latest View live


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