I'm using entity framework 4.1 in Asp.net MVC3 project, it's been deployed and now working, so now I'm gonna to update it, add some Non nullable fields and remove some fields from data base,absolutely I need my exiting data,so what's the best way to do this? is there any good tools to do that??
thanks
You could consider code first and Entity Framework Code First Migrations.
Related
I'm using Visual Studio 2017 and I'm building my first Asp.Net Core MVC site and I want to create also a Class Library (.Net Standard) as My Data Access Layer. In this last library I want to use Entity Framework to connect to my database.
I tried to use Entity Framework Core but I don't know how to create an EDMX file to map my database.
Is there another way to do this with Entity Framework Core?
Thanks in advance for your help :)
Entity framework has the power to the point that you may consider not explicitly mapping any of your database at first. Entity framework does most of the mapping for you.
I was in the same boat as you about a year ago and I got a lot of help from this example. It is the Contoso University Example: https://learn.microsoft.com/en-us/aspnet/mvc/overview/getting-started/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application
so im quite new to all spring and hibernate so i used a feature in myeclipse called generate CRUD application (it uses spring and hibernate for the heart of the application and JSF for presentation objects)that im intended to make changes so that i can work with .. my question is the following .. after i made the application that works fine by the way , i discovered that there are fields and probably even tables to be added to the database(an oracle 11g instance database)..so my questions are the following:
if i create the classes and update the existing .. will it be written directly in the database?
if not is there any way to do it because i dont think a direct update in the database will be a good idea ..
thank you in advance ..
If I understand correctly, you want to know whether the database schema can be created/updated automatically from your #Entity classes, and how to enable/disable such creation. Yes, it's possible by using some property. The name of the property would depend on your project kind. For example, in a default Spring Boot application, you can have
spring.jpa.hibernate.ddl-auto: update
in application.properties. The value update above will have the schema automatically created on first run and then updated on subsequently. validate instead of update won't alter the schema, but just validate it.
This stackoverflow post lists the possible values and their behaviour.
I've got an Oracle database that I access through Entity Framework and I am seeing a performance hit on selects where I hit tables with CLOB columns in them.
If I break out the query generated by Entity Framework I get similar results when simply calling ExecuteReader using an OracleCommand, but I can improve performance a lot by setting InitialLOBFetchSize to -1 on the OracleCommand.
I would like to do the same for Entity Framework.
How do I tell Entity Framework to set InitialLOBFetchSize to -1?
This is for Entity Framework 4.
I had the same problem few years ago and I ended up using a wrapped OracleConnection, OracleCommand, DbProviderFactory and other ADO.NET classes, and Entity Framework provider so any operation EF does with instances of these classes I was able to inject any functionality in or change the command or connection configuration.
I am building an ASP.Net MVC 3 web application using Entity Framework 4.1 with the Database First Approach.
I have just setup my solution with separate projects for the following:
UI - MVC app
Model - Class Library
POCOs - Class Library
Repositories - Class Library
Services - Class Library
I have set this up a few times before without any trouble, but now when I try to create a controller in my MVC app, I get the following error:
Unable to retrieve metadata for 'Entityname'. An item with the same key has already been added.
This happens when I try to add any controller with an Entity for its Model class. I am stumped with this. I tried re-creating the model from the db and regenerated my POCO classes, but still this problem exists.
Can anyone please help?
Thanks.
I solved it. When Entity Framework created my entity data model, some of the names it gave to the navigation properties were a bit meaningless. I therefore edited a couple of these properties, however, I ended up naming two different navigation properties, with the same type of association, the same name. Needless to say EF didn't like this. I renamed the offending navigation property. It was a tough one to fix as there were no compile errors from the model.
Here is my question: does anyone know how to set up custom validation for NetTiers entities?
I have a NetTiers web solution that was generated with the EntLib 4.1 validation app block. The actual entities' properties are decorated with the validation attributes to ensure that the dataase integrity is maintained. What I need to do is add custom validation to the entities.
I know how to write the custom validators. I'm just not sure how to wire them up to the each entities so that I can perform custom validation. What I am looking for is an overview on how to do this.
Any help would be appreciated.
Thanks,
Joe
Are you using the latest release of .netTiers? Support for data annotations was added in this patch and committed to core.
I would take a look at the following documentation. I'm thinking that this is something that you would need to wire up programmatically. Well make sure that this scenario works in v3.