What's the quickest way to generate Entity Framework model code given an SQLite database? - entity-framework

I've got an SQLite database defined by an SQL DDL (CREATE TABLE etc.) script and am to derive Entity Framework model classes to work with it.
In the past, when I had an opportunity to try Visual Studio 2013 Ultimate and Microsoft SQL Server in the same situation, Visual Studio allowed me to use "database-first" approach and reverse-engineer the model to create the model classes automatically. But I can't find anything like that available in Visual Studio 2015 Community and SQLite.
Am I missing something or are there, perhaps, 3-rd party tools that can do the job to set me free of mechanically typing all the model code manually?

If you use VS Express you are out of luck, since you cannot install DDEX providers or any other extensions using that edition. Use Community, the download sqlite-netFx46-setup-bundle-x86-2015-1.0.104.0.exe from http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki (see my blogpost here for detailed info: http://erikej.blogspot.dk/2014/11/using-sqlite-with-entity-framework-6.html )
If you use EF Core, upgrade to Community, and install the latest daily of my VS extension SQLite Toolbox, which has a feature to generate an EF Core Model via GUI https://github.com/ErikEJ/SqlCeToolbox/wiki/Release-notes

Related

Entity Framework Power Tools - cannot connect to Oracle

I have just installed Entity Framework Power Tools Beta 4 into Visual Studio 2013. I am running a .NET framework 4.5 project, using Entity Framework code first with an Oracle database. I have installed the latest ODP.NET from Oracle (version 12), including the EF drivers, and I have Oracle.ManagedDataAccess and Oracle.ManagedDataAccess.EntityFramework referenced in my project.
This set up allows me to run my project and read and access data from the Oracle database. It all works fine. My problem is when I try to use the Entity Framework Power Tools. I can specify a connection using the Oracle database name and credentials, and the dialog says 'Test Connection succeeded'. However, after clicking the next button, I get the following error:
System.Data.ProviderIncompatibleException: The store provider factory type 'System.Data.OracleClient.OracleClientFactory' does not implement the IServiceProvider interface. Use a store provider that implements this interface.
I am confused because my project is able to use the installed ODP.NET as is to communicate with the Oracle database via Entity Framework. Most of the research I have done on the WWW suggests there should be a problem with versions and the contents of the web.config - but if this is the case surely I wouldn't be able to use EF with Oracle in my project without errors?
Is it just the case that the Power Tools do not work with Oracle?
Cheers!
Martin
As Christian says in his comment, you need to install ODP.NET as a provider that Power Tools can use. I did this by installing Oracle Developer Tools for Visual Studio.

EF reverse engineer code first doesn't work in VS 2015

I installed EF Power tools in VS 2015 and i have entity framework nuget package version 6.1.3 and when i try to use reverse engineer code first, the tool doesn't work at all.
The tool creates the context class only with no table classes or mapping folder as it was working in VS 2013.
Any fix or workaround for this bug ?
You can just use the built-in EDM Wizard (Add New ADO.NET Entity data Model) to generate Code First from Database code. You could also consider using the "EF Reverse POCO Template" available on the VS gallery (in Tools/Extensions and Updates)

Cannot generate DB from EDMX - XAML file does not exist

In an EF project with an EDMX entity model, when I right click and hit Generate database from Model... I get the error:
An exception occurred while attempting to generate the database script from the model because the specified workflow file 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\DBGen\Generate T-SQL Via T4 (TPH).xaml' does not exist.
No XAML files featuring the word 'generate' exist at all on my hard disk. I thought I installed all I need with VS 2013 and the NuGet packages.
I also installed Entity Framework 6 Tools for Visual Studio 2012 & 2013 but no XAML files were added, the error still appears.
On MSDN, the generate database wizard is discussed under ADO.NET Entity Data Model Tools (http://msdn.microsoft.com/en-us/library/vstudio/bb399249(v=vs.100).aspx) but I can't find it to download online or from the VS extensions 'store'.
In Windows Programs and Features I have these items containing "entity":
Entity Framework 6.1.2 Tools for Visual Studio 2013
Entity Framework Designer for Visual Studio 2012 -enu
What am I missing?
I think my old project was set to use TPH but that strategy is no longer available, or was never available and I forgot that I installed the Powerpack to get it. Or maybe never used TPH.
This quote is interesting from a blog:
"Got the EF Powerpack that allowed generating TPH mappings." - http://www.jefim.eu/blog/2013/01/entity-framework-tpt-vs-tph.html
PowerPack here: https://visualstudiogallery.msdn.microsoft.com/df3541c3-d833-4b65-b942-989e7ec74c87
I seem to recall (I have been on a no-sql contract for years and last touched EF in v4) that I didn't like Table-per-Hierarchy and should be using Table-per-Type. I get the feeling that in the last couple of years, this has become the general feeling in EF or perhaps model-first was 'de-emphasised' in favor of code-first, which does support TPH and does database generation some other way? Guessing.
So I think the answer is that:
With Model-first, TPH is not available, use TPT.
If TPH is really wanted, then use the PowerPack (though it says VS2010) or maybe go code-first.

Using Visual Studio Online (VSO) for SQL Server Source Control

I have been looking for solutions to providing source control for my SQL Server 2012 instance. I have looked at Red-Gate's solution but it is outside my price range. Since I already make use of Visual Studio Online (VSO) source control for my .NET projects I was wondering if it was able to provide source control for SQL Server?
I have seen articles (listed below) that discuss using Team Foundation Server (TFS) for source control however I do not have a dedicated TFS server, just VSO.
Use Team Foundation Server (TFS) as your Source Control in SSMS
Using the TFS as a source control repository for SSMS projects
Has anyone made use of VSO to handle source control for their SQL Server database?
I would definitely recommend using Visual Studio Online or Team Foundation Server to hold your database scheme in version control. There is a fairly recent article in Visual Studio Magazine that discusses using the SQL Server Data Tools (SSDT) to be able to make that easier for you: Simplifying Development with Visual Studio Database Projects. SSDT is available for any version of Visual Studio including the Community and Express editions.
Redgate was out of my price range too unfortunately...
The SSDT tools for VS are amazing, and i recently started using it for comparing DB versions - and then generating change scripts.
Here's a start point if you want to get into that...
Other Free Alternatives?
Liquibase
gitSQL
Liquibase - i couldn't get my head around but if you can get it working, it may be better for other databases, if you have the requirement to use other databases.
I use gitSQL - it's free up to 20 tables...
If you have more than 20 tables then it costs $40 - which is still so much cheaper than the redgate solution.
gitSQL are also setting up command line options in a future release, so potentially you could run it via a batch file, and set up continuous integration.
gitSQL are also talking about postgres, mysql editions in the future.

How best create a visual model of EF Code First after VS2013 Update 2?

I know the EF Power Tools offers this but am loath to install them after installing VS2013 Update 2 since some of the Power Tool features are now part of Update 2. I already spent a good part of yesterday reinstalling VS2013 w/ integrated Update 2 after installing/uninstalling EF 6.1.0 Tools broke using the ADO.NET project templates. Is there anything built into Update 2 that allows this?
Honestly, the quickest way is usually by generating a database diagram via SQL Server Management Studio. Assuming the database has been generated, and your question is meant purely as a visual representation of the model.