Entity FrameWork version 6 does not update Stored Procedure - entity-framework

I am using an stored procedure with Entity Framework version 6. I added a new column to my query and then updated the edmx model from the database but do not see the new column.
Has anyone had this problem and how can I get the new column to be included?

Thanks to bcesars suggestion I deleted the stored procedure from the data model and added it back and the new column was included in the new model.
Thanks again

Related

Entity Framework 5 renaming - Database First

I'm using Database First approach and I have table called Campus and when I add to my edmx from SQL Server and I see that it renamed to Campu why is that doing?
I'm guessing that your project is having some table pluralization problems. So when your table Campus is created, Entity Framework is literally reading it as an entity called a Campu that you have pluralized to be Campus.
See this link on how to change pluralization.
But this isn't really a problem right? You can change your model name back to Campus.

If I use EF Code First then how can I add another column to a table?

I created POCO classes and then EF created the database tables for me when I tried to access the data. This worked without problem. I have now populated my tables with data. Not just seed data but real data.
Now I would like to add another column to a table. I assume the first thing I need to do is to add a field to the POCO class but what's next after that? I now have my database filled with data. On the SQL side I know how to add the column myself but do I have to do something with EF or will it automatically pick up that my column was added to the table and my field to the POCO class?
You can use Code First Migrations (http://msdn.microsoft.com/en-us/library/hh770484(v=vs.103).aspx). It can update your database automatically or not.

EF CodeFirst: Rails-style created and modified columns

Using Entity Framework CodeFirst, how do I create a created datetime column that gets populated with the current timestamp everytime a record is inserted for that table, and a modified datetime column that has a timestamp generated evertime a row is updated? Rails does this by default and I was hoping the EF generated database would have this as well, but it doesn't. Is this something that can be done with data annotations? If so, how?
Thanks!
It is not supported in EF. EF will not create these columns for you automatically. You must do it yourselves by either:
Have Created and Modified properties in every entity where you want to maintain these values. You must also manually maintain these columns in your application (common approach is overriding SaveChanges and set values accordingly).
If you don't need these values mapped (you never expect to use them in your application and you are happy with the logic in the database) you can create custom database initializer which would execute your custom SQL to alter tables and add those columns, default constraints for Created columns and update triggers for Modified columns.

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 4 updating the model when a table changes

I am using Entity Framework 4.
I have my model file with my tables on it. If I go and add a new column to one of my tables (in SQL Server) how do I update the table in the model without having to go and delete and re-adding it to the model?
Thanks
There is an option when you right click anywhere in the model (*.edmx): Update Model From Database...
Then a wizard will look for any differences (Add / Refresh / Delete). So if you need to update a table, go to the Refresh tab and select your table.
Mind you, this is only possible in an Entity Framework model, not in a LinqToSql model.