Dixin / EntityFramework.Functions

EntityFramework.Functions library implements Entity Framework code first support for stored procedures (with single result type, multiple result types, output parameter), table-valued functions (returning entity type, complex type), scalar-valued functions (composable, non-composable), aggregate functions, built-in functions, niladic functions, and model defined functions.
https://weblogs.asp.net/Dixin/EntityFramework.Functions
MIT License
79 stars 27 forks source link

{ComplexType} for method {FunctionName} is not supported in conceptual model as a structual type. #8

Closed uzser closed 8 years ago

uzser commented 8 years ago

When I'm defining entities with ComplexType attribute in other assembly and I call a table-valued function, I'm getting excepton

"{MyComplexType} for method {MyFunctionName} is not supported in conceptual model as a structual type."

It's successful when entities in same assembly with function. Exception throws because model.ConceptualModel.ComplexTypes has that entity type with other full name (assembly name of type changed to assembly name of function). Maybe it needs to search by type name instead full name (Function.DbModel.cs, line 694). The same issue is in other places. Thanks.

Ozzian commented 8 years ago

I'm doing the same and debugged the problem. Setting structuralType with name (not fullname) would fix my problem also.

?? model.ConceptualModel.ComplexTypes.FirstOrDefault(structuralType => structuralType.Name.EqualsOrdinal(clrType.Name));

Dixin commented 8 years ago

This is caused by Entity Framework registering entity type and complex type from different namespace/assembly with incorrect namespace. Searching just by Name is not strong enough. The fix is:

piyey commented 7 years ago

I have this error for int type returned in stored procedure:

[StoredProcedure(NameOf(uspTest), Schema = "dbo")] 
public virtual ObjectResult<long?> uspTest(string i_Params) 
{ 
var i_ParamsParameter = i_Params != null ? 
new ObjectParameter("I_Params", i_Params) : 
new ObjectParameter("I_Params", typeof(string)); 

return ObjectContext().ExecuteFunction<long?>("uspTest", i_ParamsParameter); 
} 

Error:

System.Nullable`1[[System.Int64, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] for method uspTest is not supported in conceptual model as a structural type.

Jaans commented 3 years ago

I'm also getting this error. Using Table Valued Function that returns int? but obviously I cannot register that as a complex type.

@piyey Did you manage to resolve your issue with long? ?