Update wizard not responding - entity-framework

Every time I need to update my emdx from database, the update wizard takes an incredible amount of time to do so rendering itself as not responding once you hit the finish (as finish the update) button.
I use Visual Studio 2015 and LocalDb SQL Server 2014. Some people suggested to install the Service Pack 1 to address the issue. I have installed the SP1 for LocalDb, but it has not helped. My installation of VS2015 is also rather new.
I have the latest Entity Framework 6 version (from nuget).

Setting the compatibility level of the database to 110 has worked for me.
To check the compatibility level, run this script:
select compatibility_level from sys.databases where name = '<YOUR_DB_NAME>'
To set the compatibility level, use this script:
alter database <YOUR_DB_NAME> set compatibility_level = 110

Running the following on the DB worked for me:
ALTER DATABASE SCOPED CONFIGURATION SET LEGACY_CARDINALITY_ESTIMATION=ON
Then, after the update, setting it back using:
ALTER DATABASE SCOPED CONFIGURATION SET LEGACY_CARDINALITY_ESTIMATION=OFF
This is per this thread over at the EF6 repo on Github.
It should be noted that the following is also reported in that thread to work though I have not tested it because the former worked so well for me:
UPDATE STATISTICS sys.syscolpars
UPDATE STATISTICS sys.sysschobjs
UPDATE STATISTICS sys.syssingleobjrefs
UPDATE STATISTICS sys.sysiscols
They also punted this back to the SQL Server team and opened up this issue over at Microsoft Connect.

Today, my coworkers and I left the wizard alone and let it update for ~10 minutes. While it took quite a while, it did complete. This is the best solution for us (for now), since we are unable to set the compatibility level of our DB without the proper permissions.

Changing SQL Server compatibility level or trace-flag 9481 is no option for me.
I gave EntityFramework Reverse POCO Generator a try.
https://visualstudiogallery.msdn.microsoft.com/ee4fcff9-0c4c-4179-afd9-7a2fb90f5838
It's a configurable generic T4 Template and works very well till now.
It even has an Option for the mentioned trace-flag
IncludeQueryTraceOn9481Flag = false; // If SqlServer 2014 appears frozen / take a long time when this file is saved, try setting this to true (you will also need elevated privileges).
Ironically it works fast even if the flag is off :)
Seems like they are using different queries for metadata compared to the VS EF Designer.

I still had to do this with Microsoft SQL Server 2014 (SP2-GDR) (KB4019093) - 12.0.5207.0 (X64) Jul 3 2017 02:25:44 Copyright (c) Microsoft Corporation Standard Edition (64-bit) on Windows NT 6.3 <X64> (Build 9600: ) (Hypervisor) using Entity Framework 6.2.0. How in the world has this not yet been solved?!

MariaDB Lethargic Manual Remedy
Using EF6, VisualStudio 2015 against MariaDB 10.2.
Just like #Santhos indicated, blowing away a ton of time for me. Seems like VisualStudio is slow at parsing that huge XML file (my development machine only has 8gb RAM). No joke, about 15 minutes to refresh.
I learned that manually 'resetting' a couple of files, then proceeding through the GUI update squared me away quickly. I'm in and out with shiny new models ~1-2 mins.
Manual Refresh Steps
Replace the contents of your .edmx.diagram file with the EDMX Diagram Boilerplate below
Replace the contents of your .edmx file with the EDMX Runtime Boilerplate below
Return to VisualStudio, double-click your EDMX > in the right click in the empty screen > Update Models from Database
EDMX Diagram Boilerplate
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
<edmx:Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
<!-- Diagram content (shape and connector positions) -->
<edmx:Diagrams>
<Diagram DiagramId="820459acb0f543cfaf7db8643f38c2d6" Name="Diagram1" ZoomLevel="85">
</Diagram>
</edmx:Diagrams>
</edmx:Designer>
</edmx:Edmx>
EDMX Runtime Boilerplate
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
<!-- EF Runtime content -->
<edmx:Runtime>
<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="ShareDirectModel.Store" Provider="MySql.Data.MySqlClient" ProviderManifestToken="5.5" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
<EntityContainer Name="ShareDirectModelStoreContainer">
</EntityContainer>
</Schema></edmx:StorageModels>
<!-- CSDL content -->
<edmx:ConceptualModels>
<Schema Namespace="ShareDirectModel" Alias="Self" annotation:UseStrongSpatialTypes="false" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
<EntityContainer Name="ShareDirectContext" annotation:LazyLoadingEnabled="true">
</EntityContainer>
</Schema>
</edmx:ConceptualModels>
<!-- C-S mapping content -->
<edmx:Mappings>
<Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
<EntityContainerMapping StorageEntityContainer="ShareDirectModelStoreContainer" CdmEntityContainer="ShareDirectContext">
</EntityContainerMapping>
</Mapping>
</edmx:Mappings>
</edmx:Runtime>
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
<Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
<Connection>
<DesignerInfoPropertySet>
<DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
</DesignerInfoPropertySet>
</Connection>
<Options>
<DesignerInfoPropertySet>
<DesignerProperty Name="ValidateOnBuild" Value="true" />
<DesignerProperty Name="EnablePluralization" Value="true" />
<DesignerProperty Name="IncludeForeignKeysInModel" Value="true" />
<DesignerProperty Name="UseLegacyProvider" Value="false" />
<DesignerProperty Name="CodeGenerationStrategy" Value="None" />
<DesignerProperty Name="DDLGenerationTemplate" Value="$(VSEFTools)\DBGen\SSDLToMySQL.tt" />
</DesignerInfoPropertySet>
</Options>
<!-- Diagram content (shape and connector positions) -->
<Diagrams></Diagrams>
</Designer>
</edmx:Edmx>

This kind of problem usually happen because the server running SQL server it self is not in good condition.
Maybe the disk space or memory on the server is getting too low to finish the task.
Check the server that running your DB.

Related

BIML never generate Package ProtectionLevel properly

I have set my project level protection level to EncryptSensitiveWithPassword and in all my packages that I generate using BIML I have code below
<Package Name ="MyPackage" ProtectionLevel="EncryptSensitiveWithPassword" PackagePassword="mypass">
For some reason I have to set ProtectionLevel to EncryptSensitiveWithPassword manually after every time I generate package using BIDS Helper. This is a painful job. I have no clue why should not work. Any clues?
I am using 1.7.0 version of BIDSHelper downloaded from Codeplex and SQL Server Data Tools version 2012 (as you might already know the confusing part is that VS version is 2010)
Update:
Below is the new structure of biml recommended by iamdave which is not generating any ouput in the ProjectSubPath and the ExceptionDataMigrator package is still generating witth default packlage protection
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<Projects>
<PackageProject ProjectSubpath="bimlOutput"
Name = "Solution/Project"
ProtectionLevel = "EncryptSensitiveWithPassword"
ProjectPassword = "password"
>
<Parameters>
<Parameter Name="sTestParam" DataType="String">This is project parameter</Parameter>
</Parameters>
<Packages>
<Package PackageName="ExceptionDataMigrator">
</Package>
</Packages>
</PackageProject>
</Projects>
<Connections>
<Connection Name="Staging" CreateInProject="true" ConnectionString="Data Source=b.database.windows.net;User ID=h;Initial Catalog=Migration_Staging;Password=z;Provider=SQLNCLI11.1;Auto Translate=False;" RetainSameConnection="true" />
<Connection Name="Reporting" CreateInProject="true" ConnectionString="Data Source=Dev2;Initial Catalog=ng;Provider=SQLNCLI11;Integrated Security=SSPI;Auto Translate=false;" RetainSameConnection="true" />
<Connection Name="SalesForceDB" CreateInProject="true" ConnectionString="Data Source=db;Initial Catalog=SalesForce;Provider=SQLNCLI11;Integrated Security=SSPI;Auto Translate=false;" />
</Connections>
<Packages>
<Package Name="ExceptionDataMigrator" ConstraintMode="Linear" ProtectionLevel="EncryptSensitiveWithPassword" PackagePassword="password">
<Parameters>
Are you creating the packages in the same VS project as your BIML files or as a whole new solution? If I remember correctly I had a similar problem and resolved it by specifying a ProjectSubPath within the <PackageProject> node of <Projects>, as the packages being created within my BIML project were inheriting the protection level of the BIML project:
<Projects>
<PackageProject
ProjectSubPath = "Folder to save new solution"
Name = "Solution/Project Name"
ProtectionLevel = "EncryptSensitiveWithPassword"
ProjectPassword = "Password"
>
<Parameters>
<!-- Add Parameters here -->
</Parameters>
<Packages>
<Package PackageName = "Package 1" />
</Packages>
</PackageProject>
</Projects>
Be VERY CAREFUL where you point that ProjectSubPath as it will completely delete any folder that already exists at that address, regardless of what it contains, then recreate it and create your new solution within.

SQlite Entity Framework ADO.net provider error 1.0.92.0

I'm trying to understand how SQlite and entity frameworks interacts.
I create a new fresh console project in my visual studio 2013. I install the nuget packet of SQlite 1.0.92.
I create a new empty model (edmx) and try to populate it from a static example database (such as northwind.db).
After this I get this error: error 0175: the ado.net provider named "System.Data.SQLite.EF6" is not registered on the computer.
Any ideas?
Thank you
Lorenzo
After some tests I found a possible solution. Let's start from the beginning:
Download the SQLite ado.net provider from sqlite server (x86 version).
You have to manually register in the GAC those three libraries: system.data.sqlite, system.data.sqlite.ef6, system.data.sqlite.designer with gacutil
Start visual studio 2013. Add reference to nuget sqlite 1.0.92.0 (This will add reference to entity framework 6.1 too).
Your app.config will look like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite" />
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
<remove invariant="System.Data.SQLite.EF6" />
<add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".Net Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
</DbProviderFactories>
</system.data>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
</providers>
</entityFramework>
<connectionStrings>
Add a new Sqlite connection to the db in your server explorer and test it.
Now add and create a new empty ado.net entity model to your project.
This should work... but when your run the application and pick up some records in one of the dbset you will get an exception telling you that there's no ado.net provider registered for your connection (system.data.sqlite).
Go to your config file and add this to you provider section (just copy the previous sqlite line and cut the .ef6 postfix in the invariant name):
<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
Save all and rebuild the application. Now it works but if you go back to the model detail and try to refresh the model from the db you will get a provider exception again. Comment the last provider added and retry. IT WORKS!!!
I think it's due to a conflict between provider names in the syste.data.sqlite and system.data.sqlite.ef6
Despite this I can't do model first (project a model and then create a new database from it) because I get another ado.net provider exception.
Any ideas about that?
Thank you
Lorenzo
_________________ UPDATE 04-2014 _________________
After some testing and googling...
I read that when you want to use the VS design tools you have to install the right x86 version of the SQLite drivers. These drivers, to work properly with the VS tools, needs to register their version of the System.Data.SQLite in the GAC during the installation process (only after this VS knows where to find the connection provider for the design tools).
When you use the model-first approach and you ask the model to create the db instead of use the correct driver registered in you app.config it tryes to open the entity connection with the one registered in GAC and used by the visualmodel creation tool (and wich is not compatible). I think there's no way at the moment to use the VS's entity modelling tool with the SQLite provider.
Lorenzo
#LoxLox : I don't think you have to register dll with GAC. I have same problem like yours but I just need to edit the .config file as discussed in this post by adding .EF6 suffix to invariant.

SSDL Content of the edmx file emptied after update from database

I'm using Visual Studio 2010 (SP1) with EF.
When I tried to update the edmx file of my application, the SSDL Content part of the file gets emptied.
Consequences are that the mapping details of every entity is emptied, meaning tables that already exist don't refresh.
For example, the SSDL Content section looked like this before :
<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="DataAccess.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">
<EntityContainer Name="DataAccessStoreContainer">
<EntitySet Name="Amdec" EntityType="DataAccess.Store.Amdec" store:Type="Tables" Schema="dbo" />
...
After, I got that :
<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="DataAccess.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">
**<EntityContainer Name="DataAccessStoreContainer"/>**
Any clue ?
Thank you Pawel,
I used integrated security on the edmx connection string since I can access the server but I have no rights on the database itself.
I replaced it with SQL connection credential and it works fine now.

Java Webstart with Tibco Native Libs

I am trying to deploy an application that uses the native implementation of Tibrv through the TibrvJ library using Java Webstart.
I have packaged up all of the Windows dlls from inside c:\tibco\tibrv\bin into a Jar file and have added these to the nativelib element in the JNLP file.
I was hoping that webstart would take the dll files from thetibco-7.5.1-nativelibs.jar file and allow them to be loaded via System.loadLibrary which is called from Tibrv.open(). However it doesn't seem to want to work properly.
My JNLP file looks like this:
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE jnlp PUBLIC "-//Sun Microsystems, Inc//DTD JNLP Descriptor 6.0//EN" "http://java.sun.com/dtd/JNLP-6.0.dtd">
<jnlp spec="6.0+"
codebase="http://somewhere:8080/my-gui/application"
href="launch.jnlp">
<information>
<title>My GUI</title>
<vendor>Technology</vendor>
<description>Dashboard</description>
<description kind="short">Dashboard</description>
<icon href="icon/Stocks-128x128.png" />
<offline-allowed />
<shortcut online="true">
<desktop />
<menu submenu="Dashboard" />
</shortcut>
</information>
<security>
<all-permissions />
</security>
<update check="always" policy="prompt-update" />
<resources>
<j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"
java-vm-args="-Xmx120M -ea />
<property name="log4j.configuration" value="live/log4j.xml" />
<property name="swing.aatext" value="true" />
<jar href="tibrvj-7.5.1.jar" />
<jar href="dashboard-gui.jar" main="true" />
</resources>
<resources>
<nativelib href="nativelib/tibco-7.5.1-nativelibs.jar" />
</resources>
<application-desc main-class="com.somewhere.Main">
<argument>classpath:/live/client.xml</argument>
<argument>/live/live.properties</argument>
</application-desc>
</jnlp>
The application launches but as soon as a call is made to open tib then it falls apart with an error along the lines of:
[Root exception is TibrvException[error=22,message=Version mismatch: libtibrv version 7.4 does not match version of tibrvj shared library 7.5]]
TibrvException[error=901,message=Library not found: tibrvj]]
The users have a variety of Tib installations already on their PCs from Tib 7.2 through to 7.5. The Webstart Application only works correctly on a machine with 7.5 installed which matches the Jar file inside the package. So it doesn't appear to do anything with the nativelib jar.
I would like to avoid having to deploy 3 versions of the web start application for the different versions of Tib that the users have installed.
Has anyone else managed to get this combination of TibrvJ and Webstart working?
I've managed to get it working. The trouble is that the call to System.loadLibrary when using Webstart doesn't load in the dependencies of the specified library even if they have been packaged up into a nativelib jar.
See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6191612 for more info.
To get around this problem it is necessary to explicity load all of the dependencies in the correct order. It is also necessary to put each dll library into its own jar file.
So to use native TibrvJ you need to make the following calls before any calls to Tibrv.Open.
System.loadLibrary("msvcr71");
System.loadLibrary("tibrv");
System.loadLibrary("tibrvcm");
System.loadLibrary("tibrvft");
System.loadLibrary("tibrvcmq");
System.loadLibrary("tibrvj");
Happy Days!
I think you have encountered a problem with Webstart.
Some years ago, I had a Webstart application using Java 3D that didn't work on Macs. Eventually I found that all Macs some with an old version of Java 3D installed, and that already installed version was used over the newer version that I had included in the in my JNLP file. Your problem sounds almost exactly like this, so it could very well be the same problem.

Running WatiN tests with ReSharper testrunner

I'm getting started with WatiN to test my web interface. The problem I'm having is the following:
When I start the tests from within TestDriven.net, I have no problem. If I use the ReSharper test runner, I get this predictable AppartmentState exception.
I tried using the different options described here: http://watin.sourceforge.net/apartmentstateinfo.html#testdriven. Nothing helps.
Any suggestions?
I've use Resharper test runner in most of my watin test projects. To get it to work use the same method as for nunit:
http://watin.sourceforge.net/apartmentstateinfo.html#nunit
App.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="NUnit">
<section name="TestRunner" type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
</configSections>
<NUnit>
<TestRunner>
<!-- Valid values are STA,MTA. Others ignored. -->
<add key="ApartmentState" value="STA" />
</TestRunner>
</NUnit>
</configuration>
With NUnit 2.5, RequiresSTA attribute should be the tool of choice.
Using Resharper 5.1 with VisualStudio 2010 Ultimate I found that I needed to change my Resharper options to disable "Shadow-copy assemblies being tested" (found in Resharper --> Options --> Tools --> Unit Testing).
Additionally, I also found that the correct naming for the config file is the one which includes the dll extension (so: assemblyname.dll.config).