Working with EF for Oracle database. "Schema specified is not valid" - entity-framework

The field in Oracle database is of NUMBER(5), and when I generate EF models from the oracle database, it converts the field into "Int16".
There are some of the rows for that field having values such as "50000", etc, so Int16 is throwing error for obvious reasons.
Now I tried changing it to Int32, and also Decimal in EF models, but it is now giving an error saying -
Member Mapping specified is not valid. The type
'Edm.Decimal[Nullable=True,DefaultValue=,Precision=,Scale=]' of member
'Field1' in type
'MyApp_Models.MyTable' is not compatible
with 'OracleEFProvider.number
Any idea what is wrong here, and what is possible solution of this?
Any help on this much appreciated.

Set your type to just INT instead of INT32. See if that works.

Related

Getting Error for updating a row in a table using EF

I am getting this below error when I try to update a row in my table using Entity Framework.
I am able to add a new entry to table but not able to update the existing entry.
Error:-
The specified value is not an instance of type 'Edm.Decimal'\r\nParameter name: value
And my table has all the columns of type (nvarchar,char,bit,numeric,uniqueidentifier,int)
I dont even have a column of type Decimal. I dont know where this is coming from.
I am using ASP.NET MVC3 and Entity Framework. I have checked the table mapping with the Entity Framework and it looks fine.
Please help me.
Thanks,
Vivek
I found the solution. The Identity column of the table was type Numeric. It should have been type Big Int. I updated the type of column and it has worked.
Thanks,
Vivek

Object cannot be cast from DBNull to other types Entity Framework

I've got a column in one of my models that is nullable. It is nullable in the EDMX, and I've checked that it's nullable in the generated code. I've octuple-checked that it's nullable in the database. However, when I try to save an instance of the model with the column set to null, I receive the exception "Object cannot be cast from DBNull to other types." Most of the code involved here is either the Entity Framework code itself, or generated code. I have other nullable columns that do not seem to have this problem.
Has anyone run into anything like this? Googling around for things mostly reveals people who need to do if (someSqlValue == DBNull.Value) with manual ADO recordsets, but since this is EF interacting with DBNull, there's nowhere in my code that could possibly need to check this.
Unfortunately, I cannot share the code with this, and as I mentioned, most of my nullable columns do not exhibit this problem, so I am not confident in my ability to reproduce the problem in a small test case.
Have you checked that the type in your EDMX matches the type in your database (i.e. that you aren't trying to stuff a null int SQL value into a nullable DateTime field or something like that)?

Error creating compact sql database file from model

While creating compact sql database file from a model(edmx) showing following error-
There is no store type corresponding to the EDM type '{0}' of primitive type '{1}'.
I can't quiet get the error.
Please help..........
.net Time entity data type is not supported in sql ce3.5, instead used datetime and this is resolve the issue.
Thanks
Ashish

Entity Framework 4.0 & null fields in Views

We're adding some views to our entity framework model. Some fields in these views are nullable datetime2 datatypes in our sql server 2k8 db and the edmx is incorrectly showing these fields as being not null. Is this a known issue?
When I try to change them to not null it still throws the same error - because it appears as if the ssdl is defining it differently?
Has anyone run into this problem?
Edit: My exact error is:
The 'dateTimeAffected' property on
'V_myView' could not be set to a
'null' value. You must set this
property to a non-null value of type
'DateTime'
Removing the view and adding it back in does not fix it as well... still marks the field as not nullable.
Sorry for this silly answer but you did delete the tables and add them again...for some reason ef4 does not refresh them properly...but ya not a known problem with ef4 it should show them as nullable...btw what error are you getting?
you said the property is marked as a key,
but by its name it doesnt sound like this is the case.
(having it marked as key of course dosent sit well with nullablility...)
do you have a PK defined ?

Entity Framework - Mapping decimal(13,0) problem

I'm migrating the aplication of my company (that nowadays run over SQL Server and Oracle) to ASP NET MVC and Entity Framework for persistence.
A create my Entity Model based on SQL Server Database e separately I create a SSDL for Oracle (for Oracle I use DevArt dotConnect for Oracle Provider) and I get some pain troubles.
My table primary keys are on SQL Server are of type decimal(13,0) and on Oracle are number(13,0) but Oracle map it's type to Int64 and SQL Server to decimal, but I need that SQL Server map it to Int64.
I make these modification manually on Entity Data Model and for create records it's works fine, but when I have to delete or update some record I got these error:
The specified value is not an instance of type 'Edm.Decimal'
Parameter name: value
at System.Data.Common.CommandTrees.DbConstantExpression..ctor(DbCommandTree commandTree, Object value, TypeUsage constantType)
at System.Data.Mapping.Update.Internal.UpdateCompiler.GenerateValueExpression(DbCommandTree commandTree, EdmProperty property, PropagatorResult value)
at System.Data.Mapping.Update.Internal.UpdateCompiler.GenerateEqualityExpression(DbModificationCommandTree commandTree, EdmProperty property, PropagatorResult value)
at System.Data.Mapping.Update.Internal.UpdateCompiler.BuildPredicate(DbModificationCommandTree commandTree, PropagatorResult referenceRow, PropagatorResult current, TableChangeProcessor processor, Boolean& rowMustBeTouched)
at System.Data.Mapping.Update.Internal.UpdateCompiler.BuildDeleteCommand(PropagatorResult oldRow, TableChangeProcessor processor)
at System.Data.Mapping.Update.Internal.TableChangeProcessor.CompileCommands(ChangeNode changeNode, UpdateCompiler compiler)
Someone can help me?
Why Entity Framework mapping are so fixed? It could be more flexible?
Ps.: The error that I got, I suspect that is because of a association.
I have a Entity named Province and another named Country and I think that the association between these Entities are causing the problem at update and delete.
Regards,
Douglas Aguiar
This may or may not help you, but i had the same error from doing this same thing. So I edited the Conceptual model and change the primary key field from Int32 to Decimal. So far, seems to have fixed things. I still need to test again against Sql Server and make sure this didnt break it.
I was getting the error "The specified value is not an instance of type 'Edm.Decimal' Parameter name: value" as you posted in your question. I had changed the default data types from Decimal to Int32 as this better reflects the true typing. When I first hit this error I rolled back the type changes and was still getting an exception but it changed just slightly but led to further digging. Bottom line, in my scenario we were expecting a trigger to populate the PK during persistence via Before Insert directive. The problem was that the domain class built by EF was setting the PK at 0 so the trigger was never firing as the incoming PK was not null. Of course EF will not let you set the Entity PK to be nullable. Maybe this will help someone else in the future.