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

Source code checked in, #48052daebbc8

$
0
0
Added tag v2.17.2 for changeset 7ae2debbc343

New Post: Prevent generate navigation properties and collections

$
0
0
Hello!
Is it possible to add settings to prevent generation on navigation properties and collections?
It will be very useful for bounded context. For example I have a table Worker and almost all tables in database have a foreign key to that table. So after generation it has a tons of navigation properties and I need to manually remove it.

New Post: Prevent generate navigation properties and collections

Closed Unassigned: user defined table types for stored procedures are not supported [147]

$
0
0

see discussion at :

https://efreversepoco.codeplex.com/discussions/645780


Comments: Released in v2.17.2

New Post: Can user defined table types for stored procedures be supported ?

Commented Unassigned: user defined table types for stored procedures are not supported [147]

$
0
0

see discussion at :

https://efreversepoco.codeplex.com/discussions/645780


Comments: Hello, I still see the same problem with v2.17.2 the generated code for above stored procedure still returns an int instead of a table could the problem be related to the fact that this SP has both a table as INPUT parameter and another table as a result ? I have other sp's that just have a table as a result, that work fine : public List<p_GetListCaptionReturnModel> p_GetListCaption(int? organisationid, int? sitegroupid, int? siteid) public List<p_GetSensorInfoReturnModel> p_GetSensorInfo(int? sensorid, int? channelid) etc.

Commented Unassigned: Foreign key compile error - Duplicate anonymoous type property name [160]

$
0
0
I have the following Foreign key on a table in my DB:
```
ALTER TABLE [Ops].[FCMarketMapping] WITH CHECK ADD CONSTRAINT [FK_FCMarketMapping_markets] FOREIGN KEY([MarketId])
REFERENCES [reference].[markets] ([id])
GO
```
This leads to an error in the auto-generated configuartion file:
```
// Foreign keys
HasRequired(a => a.Markets).WithMany(b => b.FcMarketMapping).HasForeignKey(c => new { c.MarketId, c.MarketId }); // FK_FCMarketMapping_markets
```
The compile error is "Duplicate anonymous type property name MarketId"

I just keep having to manually comment out the auto-generated line as I don't want to remove the key from the DB. Am I doing something wrong? Anyone else having this issue?
Comments: Sounds like you are getting a duplicate in your FK columns. Not sure how. Change this line (about line 2045): ``` if(foreignKeys.Count > 1) ``` to ``` if(foreignKeys.Count > 1 && fkCols.Select(x => x.col.NameHumanCase).Distinct().Count() > 1) ``` Please let me know how you get on. If this works for you, I will make it permanent in the generator.

New Post: Prevent generate navigation properties and collections

$
0
0
Thanks. I am considering whether or not this should be an exclude Regex instead. That way you can select which FK's to exclude, instead of all of them.
See the following cases for more details

Source code checked in, #c6f8eca1bde9

$
0
0
Prevent duplicate of "using System.Data.Entity.Infrastructure;"

Source code checked in, #372d73b93443

$
0
0
Use correct case for table alias in case of case sensitive collation setting on database. Thanks to Luoti.

Source code checked in, #7ad5214e5270

$
0
0
Use an @ Symbol if default contains a new line character.

Commented Unassigned: user defined table types for stored procedures are not supported [147]

$
0
0

see discussion at :

https://efreversepoco.codeplex.com/discussions/645780


Comments: Hi, I'm experiencing the same issue. Please can the issue be reopened. Cheers, Andy

New Post: Navigation properties collection type

$
0
0
How I can generate IList navigation properties collection instead of ICollection? In my .tt file I have set CollectionType = "List", but navigation properties are generated as ICollection.

New Post: Navigation properties collection type

$
0
0
In EF.Reverse.POCO.Core.ttinclude, search for ICollection and change it to IList.

There are two lines to change:

Line 2600:
ReverseNavigationProperty.Add(string.Format("public virtual ICollection<{0}> {1} {{ get; set; }}{2}", fkTable.NameHumanCase, propName, includeComments ? " // " + constraint : string.Empty));
Line 2605:
ReverseNavigationProperty.Add(string.Format("public virtual ICollection<{0}> {1} {{ get; set; }}{2}", fkTable.NameHumanCase, propName, includeComments ? " // Many to many mapping" : string.Empty));

Created Unassigned: ReadStoredProcReturnObject throws an exception if a parameter contains a user defined type [173]

$
0
0
Hi,

The generated query used to work out the return model of a stored proc in invalid if it contains a user defined type.

The tool generates the following query for a stored proc in my database:

```
SET FMTONLY OFF; SET FMTONLY ON;
EXEC [Products].[ShipGoodsOut] @carrier=null, @service=null, @trackingNumber=null, @goodsOutIds=null
SET FMTONLY OFF; SET FMTONLY OFF;
```

The last parameter is a user defined table type:

```
CREATE TYPE [dbo].[Ids] AS TABLE(
[Id] [int] NOT NULL
)
```

Running the generated query gives the following error:

> Msg 206, Level 16, State 2, Procedure ShipGoodsOut, Line 13
Operand type clash: NULL is incompatible with Ids


That causes an exception and means the code required to populate the return model is never generated and so it fallsback to the code required to set the out parameter.

If I change the query such that it looks like this:

```
SET FMTONLY OFF; SET FMTONLY ON;
DECLARE @carrier varchar(25)
DECLARE @service varchar(25)
DECLARE @trackingNumber varchar(25)
DECLARE @goodsOutIds [dbo].[Ids]
EXEC [Products].[ShipGoodsOut] @carrier, @service, @trackingNumber, @goodsOutIds
SET FMTONLY OFF; SET FMTONLY OFF;
```

It works fine.

Commented Unassigned: ReadStoredProcReturnObject throws an exception if a parameter contains a user defined type [173]

$
0
0
Hi,

The generated query used to work out the return model of a stored proc in invalid if it contains a user defined type.

The tool generates the following query for a stored proc in my database:

```
SET FMTONLY OFF; SET FMTONLY ON;
EXEC [Products].[ShipGoodsOut] @carrier=null, @service=null, @trackingNumber=null, @goodsOutIds=null
SET FMTONLY OFF; SET FMTONLY OFF;
```

The last parameter is a user defined table type:

```
CREATE TYPE [dbo].[Ids] AS TABLE(
[Id] [int] NOT NULL
)
```

Running the generated query gives the following error:

> Msg 206, Level 16, State 2, Procedure ShipGoodsOut, Line 13
Operand type clash: NULL is incompatible with Ids


That causes an exception and means the code required to populate the return model is never generated and so it fallsback to the code required to set the out parameter.

If I change the query such that it looks like this:

```
SET FMTONLY OFF; SET FMTONLY ON;
DECLARE @carrier varchar(25)
DECLARE @service varchar(25)
DECLARE @trackingNumber varchar(25)
DECLARE @goodsOutIds [dbo].[Ids]
EXEC [Products].[ShipGoodsOut] @carrier, @service, @trackingNumber, @goodsOutIds
SET FMTONLY OFF; SET FMTONLY OFF;
```

It works fine.
Comments: This is the cause of issue [147](https://efreversepoco.codeplex.com/workitem/147).

Commented Unassigned: ReadStoredProcReturnObject throws an exception if a parameter contains a user defined type [173]

$
0
0
Hi,

The generated query used to work out the return model of a stored proc in invalid if it contains a user defined type.

The tool generates the following query for a stored proc in my database:

```
SET FMTONLY OFF; SET FMTONLY ON;
EXEC [Products].[ShipGoodsOut] @carrier=null, @service=null, @trackingNumber=null, @goodsOutIds=null
SET FMTONLY OFF; SET FMTONLY OFF;
```

The last parameter is a user defined table type:

```
CREATE TYPE [dbo].[Ids] AS TABLE(
[Id] [int] NOT NULL
)
```

Running the generated query gives the following error:

> Msg 206, Level 16, State 2, Procedure ShipGoodsOut, Line 13
Operand type clash: NULL is incompatible with Ids


That causes an exception and means the code required to populate the return model is never generated and so it fallsback to the code required to set the out parameter.

If I change the query such that it looks like this:

```
SET FMTONLY OFF; SET FMTONLY ON;
DECLARE @carrier varchar(25)
DECLARE @service varchar(25)
DECLARE @trackingNumber varchar(25)
DECLARE @goodsOutIds [dbo].[Ids]
EXEC [Products].[ShipGoodsOut] @carrier, @service, @trackingNumber, @goodsOutIds
SET FMTONLY OFF; SET FMTONLY OFF;
```

It works fine.
Comments: I have already made and tested a change in my own project. I have forked the repository and hope to raise a pull request. But in the mean time, I have changed ReadStoredProcReturnObject to look like this: ``` var sb = new StringBuilder(); sb.Append("SET FMTONLY OFF; SET FMTONLY ON; \n"); if (proc.IsTVF) { sb.Append(String.Format("SELECT * FROM [{0}].[{1}](", proc.Schema, proc.Name)); foreach (var param in proc.Parameters) { sb.Append("null, "); } sb.Length -= 2; sb.Append(")"); } else { foreach (var param in proc.Parameters) { sb.AppendLine(String.Format("DECLARE {0} {1}", param.Name, param.SqlDbType == "Structured" ? param.UserDefinedTypeName : param.SqlDbType)); } sb.Append(String.Format("exec [{0}].[{1}] ", proc.Schema, proc.Name)); foreach (var param in proc.Parameters) { sb.Append(String.Format("{0}, ", param.Name)); } sb.Length -= 2; } sb.Append("\n SET FMTONLY OFF; SET FMTONLY OFF;"); ```

Commented Unassigned: user defined table types for stored procedures are not supported [147]

$
0
0

see discussion at :

https://efreversepoco.codeplex.com/discussions/645780


Comments: @mhwlng I've raised a separate issue for our specific case [173](https://efreversepoco.codeplex.com/workitem/173).

Commented Unassigned: ReadStoredProcReturnObject throws an exception if a parameter contains a user defined type [173]

$
0
0
Hi,

The generated query used to work out the return model of a stored proc in invalid if it contains a user defined type.

The tool generates the following query for a stored proc in my database:

```
SET FMTONLY OFF; SET FMTONLY ON;
EXEC [Products].[ShipGoodsOut] @carrier=null, @service=null, @trackingNumber=null, @goodsOutIds=null
SET FMTONLY OFF; SET FMTONLY OFF;
```

The last parameter is a user defined table type:

```
CREATE TYPE [dbo].[Ids] AS TABLE(
[Id] [int] NOT NULL
)
```

Running the generated query gives the following error:

> Msg 206, Level 16, State 2, Procedure ShipGoodsOut, Line 13
Operand type clash: NULL is incompatible with Ids


That causes an exception and means the code required to populate the return model is never generated and so it fallsback to the code required to set the out parameter.

If I change the query such that it looks like this:

```
SET FMTONLY OFF; SET FMTONLY ON;
DECLARE @carrier varchar(25)
DECLARE @service varchar(25)
DECLARE @trackingNumber varchar(25)
DECLARE @goodsOutIds [dbo].[Ids]
EXEC [Products].[ShipGoodsOut] @carrier, @service, @trackingNumber, @goodsOutIds
SET FMTONLY OFF; SET FMTONLY OFF;
```

It works fine.
Comments: I give up! Why is it so hard to push a change?

New Post: Add marker interfaces to certain POCO classes

$
0
0
I would like to be able to mark some of my generated POCOs with a marker interface that guarantees they implement a given property.

For example;
public interface IHasCode
{
    string Code { get; }
}

// Generated:
public class Employee : IHasCode
{
    public Guid Id { get; set; }
    public string Code { get; set; }    
}
There are a couple of ways I can think of:
  1. Make all generated classes partial, so I can create another file for those I want to, and add the interface there.
  2. Have the generated code implement the interface for those POCOs that meet a certain criteria (regex wouldn't cut it - it'd have to be a Func<[class definition], bool> or something that allows me to inspect the properties and see if there's a column called "Code").
Viewing all 1642 articles
Browse latest View live


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