We have built a product around EF4 with POCO and the initial requirements were to work against SQLServer 2005. However, we have a few clients who have SQLServer2008 installed. Hence, at runtime, we need to verify the version of the DB and make changes to the manifest token in the edmx accordingly. Or, can it be done to read the ProviderManifestToken from a web.config and build the edmx at runtime. Our client doesn't want one installer per DB version.
Thanks,Murali
Eventhough the actual database is SqlServer2008 you can still have a ProviderManifestToken value of 2005. So unless you are building two different versions of your software, where one targets (and uses the features of) SqlServer2008, you can just keep it as is.
Related
I'm in the process of converting the existing .Net framework project that uses EF 6 with Database First approach (EDMX) file to .Net Standard 2.1 which connects to SQLDB hosted on Azure.
Existing EDMX file has a constructor (auto generated) that accepts ConnectionString as given below -
public TestDatabaseConnection()
: base(ConfigurationManager.ConnectionStrings["TestDatabaseConnection"].ConnectionString)
{
}
This is breaking for two reasons -
ConfigurationManager.ConnectionStrings works only in .Net framework projects and throw runtime errors in the .Net Core project (for eg- ConfigurationManager.ConnectionStrings returns null).
I need to make changes to the above code to use the AppAuthentication nuget as mentioned in the MSDN docs here
So, what are the options available in order to make this work so that I could use the same nuget package for connecting to the database via EF 6 (database first) for both .net framework and .net core projects?
Is the only available is to convert to Code first and make the necessary changes as mentioned in the above MSDN link?
We have a large C# EF Code First based code base. Recently one F# project was added. The project uses FSharp.Data.SqlClient (http://fsprojects.github.io/FSharp.Data.SqlClient/) type provider to connect to DB.
That created a huge problem: F# type provider needs DB (and all referenced structures) to exist before the whole project can be complied from scratch, but EF needs to compile the whole project before it can create / update the DB. Subsequently, the DB can no longer be created from scratch or even modified.
While not using type providers is, obviously, possible, it is not an appealing solution because it nullifies the whole purpose of type providers and requires writing code that's already done by them.
Does anyone has any ideas how to deal with that? Thanks a lot!
Expanding on my comment, assuming you have currently only 2 VS projects:
Your C# project that contains everything including the EF code
Your F# project that contains the code that uses the type provider
What you could do is turn in into a 3 project solution:
A new and small C# project that only does EF stuff (migrations, schema definition, classes declaration)
Your F# project that contains the code that uses the type provider
Your existing C# project that would not contain the ef classes and ef related things but that references both #1 and #2.
That way, you EF C# project can compile first then run the migrations. Then your F# project would compile fine. Finally your 3rd project (that contains the rest of the logic that depends on both the EF and F# projects) can compile successfully.
I am using entity framework with DB first approach. I have migrated from EF5 to EF6 successfully. In EF5, I was using pre generated views to improve startup performance. In EF6, it is not working. I have generated views using power tool. Power tool generated it successfully and I can build the application without any error.
But When I run it, getting following error:
The current model no longer matches the model used to pre-generate the mapping views, as indicated by the ViewsForBaseEntitySetsfc4437b421d2fd7f4d645bf31e3cb5b1b8374d9c77a07ef5f36c1cac0bfea31a.MappingHashValue property.
Pre-generated mapping views must be either regenerated using the current model or removed if mapping views generated at runtime should be used instead
I am not able to understand why there is difference between the hash value generated via power tool and generated by EF at run time. There is no change in the edmx file.
There are more than 290 entities in edmx.
Version of entity framework in 6.1.3.
Power tool is VSPowerTools-Beta4.
I am using visual studio 2013.
Code generation startegy of edmx is 'Legacy ObjectContext'.
i m using publish option for my project using Entity framework.
the 'bin' of the published folder does contain the dll of project that has Entity framework but the features of my application (using EF) stop working when they Get / Insert Data using Entity Framework .
the error is as follows in my application's File log:
02/01/2015 10:25:36 AM|TraceError |Exception is :The specified store provider cannot be found in the configuration, or is not valid.| |<EOL>
Am i missing any thing? ... Please help.
This might be happening due to system architecture of processors (32 bit and 64 bit versions of dll).
Try the following steps.
Open Inetmgr (IIS).
Go to application pools.
Open advance properties of the application pool on which your application is running.
Set Enable 32 bit Applications (in general category) to True.
I think this will solve your issue.
If you are using an Oracle database, I assume you must have installed the ODP.NET components. Unless you are using a third party provider such as Devart, which offers direct access to Oracle with its DirectConnect feature, there has to be a middle layer that the developer installs which would translate EF to Oracle. (Even if you used a third party provider, then you must have installed that third party provider on your development environment). Long story short, your VM does not have the provider that your developer PC has. You need to find out if you are using ODP.NET or a third party provider on your development PC, (which, I guarantee you, does not come with any Visual Studio or framework installation, somebody has to install it separately), then install it on your VM
I have created an Web API application using EF code first which I want to deploy it to production.
I want to move it to production, so how should I share my MVC App with client & also in production how we will be creating databases as there would be no visual studio present there
(usually in local when we run the project in VS database gets generated if we are using code first)
We use for the exact same scenario Entity Framework Migrations.
It works without any problems.
You can easily change the database from version to version.
Also downgrading is supported.
With some third party tools you can also add other dbms then SQL Server.
See http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/migrations-and-deployment-with-the-entity-framework-in-an-asp-net-mvc-application for some more information.