Generate edmx file from SQL query programmatically

I am trying to find a way to generate an edmx file from a request, I understand that we can update the model from the database. However, in my case, we save all the SQL definition scripts in a file. I need a way to generate edmx from these scripts instead of running the script file in the database and then re-creating the edmx from the database.

+3


source to share


2 answers


The reason this is usually not possible is to edmgen

request a list of DB entities and their properties. But in "w370" there are no "entities" or anything else, just SQL style text. It needs to be parsed and executed (whatever the form it takes), with something that understands that very taste of SQL, to create some representation of these objects so that they can be validated - that is, at least a semi-functional SQL server.

If you don't want to worry about a full MSSQL installation and DB deployment (I believe this is the main reason for the question), you can use the SQL Server Compact that comes with every VS installation. It stores the DB in a single file where you specify (like BerkleyDB or SQLite), which you can delete afterwards.



Weblog Steve Lasker - Creating a SQL Server Compact Edition Database and Schema in Code explains one way to do it in .NET code. There's also a third party sqlcmd

analogue for mssql compact - sqlcecmd

with which you can do the same directly from the command line.

The differences between SQL Server Compact and SQL Server retain the same limitations. Most radical about DDL is the lack of procedures, views and advanced metrics. But they are not used by vanilla (as opposed to the highly customized) Entity Framework anyway.

+1


source


Unfortunately, there is no direct way to do this. During early development of VS 2012, it was possible to use an entity framework database project, but this feature did not make it into the final product:



http://blogs.msdn.com/b/ssdt/archive/2012/03/09/ef-integration-removed-from-sql-server-data-tools.aspx

+1


source







All Articles