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

Commented Issue: DataMember isRequired [4]

$
0
0
Referencing version 1.5.0.

The DataMember attribute for 'isRequired' is not working as expected. Columns from the database that are set as nullable are set to 'isRequired=true' and columns that are not-nullable are set to 'false'.

__Changing line 75 of EF.Reverse.POCO.ttinclude__
__from:__
<# if(AddWcfDataAttributes) { #> [DataMember(Order = <#=DataMemberOrder++#>, IsRequired = <#=col.IsNullable ? "true" : "false"#>)]
__to:__
<# if(AddWcfDataAttributes) { #> [DataMember(Order = <#=DataMemberOrder++#>, IsRequired = <#=col.IsNullable ? "false" : "true"#>)]

Sets the 'isRequired' attribute to the expected values based on the column specification from the database.
ie: a table column that is nullable is set to isRequired=false

Comments: I loaded v1.5.0 today and set: AddWcfDataAttributes = true; Upon generating the entities I noticed these attributes didn't line up with my tables and when using them in WCF the types would error out (as the database had existing values with null data in some columns). I tested by changing the line indicated and regenerated the entities. The attributes then lined up better with my data. Unless my sandbox app is totally messed up - I thought I'd share. I'm hoping to use this to more quickly build a new WCF service app and save time by not having to create my own entities. Looks like it may work out so far! Thank you!

Viewing all articles
Browse latest Browse all 1642

Trending Articles



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