Error creating compact sql database file from model - asp.net-mvc-2

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

Related

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

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.

Entity Framework - View Sql using toTraceString

I'm trying to view the generated sql that Entity Framework 5.0 generates from an entities query. All over the web, everyone says to cast the IQuerable object to an ObjectQuery object and then use the toTraceString() method to return the generated query.
However I keep getting an invalid case exception:
Unhandled Exception: System.InvalidCastException: Unable to cast object of type
'System.Data.Entity.Infrastructure.DbQuery`1[System.String]' to type 'System.Data.Objects.ObjectQuery'.
What is the new way to do this in Entity Framework 5?
You can view the generated SQL from an IQueryable using .ToString(), e.g.
var query = context.People.Where(x => x.DomainId == 1);
Console.WriteLine(query.ToString());
Are you using SQL Server? If so, try using the profiler. Tools->SQL Server Profiler in the development version of Management Studio

Is Time Datatype in SQL Server 2008 R2 supports Entityframework with MVC4

I am using ASP.NET MVC4 with Entityframework.
Does Entityframework supports new Time datatype of SQL.
Thank you
Yes it is supported. If you have table which uses Time SQL type it will be recognized as EDM.Time and generated entity will use TimeSpan as property type. In the same way it works with code first approach. If you map property with TimeSpan type the table will contain SQL Time column.

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

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.