生成SQL从实体框架模型SQLite数据库

编程入门 行业动态 更新时间:2024-10-15 14:19:55
本文介绍了生成SQL从实体框架模型SQLite数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否有可能生成的模型与实体框架SQLite数据库?我创建了一个SQLite的连接,并创建了一个模型,但是当我点击生成模型数据库我得到的下面,它看起来像MS SQL,如果使用SQLite(文件刚开始的时候)执行使得错误:

- ------------------------------------ -------------- - 实体设计DDL脚本对于SQL Server 2005,2008,和天青 - ------------------------------------------------ - - 创建日期:11/25/2010 0时26分41秒 - 从生成EDMX文件:G:\富\酒吧\ Model1.edmx - ------------------------------------------------ - SET QUOTED_IDENTIFIER OFF; 走 使用[foobar.sqlite] 走 如果SCHEMA_ID(N'dbo')为空EXECUTE(值为N'create SCHEMA [DBO]'); 走 ...

我的连接字符串看起来像下面,所以我肯定选择了正确的数据库类型:

'metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SQLite;provider连接字符串=数据源= G:\富\酒吧\巴兹'

难道不应该以这种方式工作?

编辑:

由于没有人似乎知道答案,我会更容易?是否有可能生成SQL code与EF比对MICROSOFT SQL SERVER以外的任何数据库

解决方案

我一直在寻找一个解决方案,这一点,当我偶然发现此链接:$c$c.msdn.microsoft/Demo-of-ADONET-POCO-with-140ad3ad

将在C SSDLToSQLite3.tt文件:\程序文件(x86)\微软的Visual Studio 10.0 \ Common7 \ IDE \扩展\微软\实体框架TOOLS \ DBGEN,你应该能够选择这个作为DDL生成模板在实体设计。

一旦你这样做,该模型将创建SQL适合SQLite的。

Is it possible to generate a SQLite database from the model with entity framework? I created a SQLite connection and created a model, but when I click "Generate database from model" I get the following, which looks like MS SQL and makes errors if executed with SQLite (Just the beginning of the file):

-- -------------------------------------------------- -- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure -- -------------------------------------------------- -- Date Created: 11/25/2010 00:26:41 -- Generated from EDMX file: G:\Foo\Bar\Model1.edmx -- -------------------------------------------------- SET QUOTED_IDENTIFIER OFF; GO USE [foobar.sqlite]; GO IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]'); GO ...

My connection string looks like the following, so I definitely chose the right database type:

'metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SQLite;provider connection string="data source=G:\foo\bar\baz"'

Shouldn't it work this way?

EDIT:

Since nobody seem to know an answer I'll make it easier: Is it possible to generate SQL code with EF for any database other than the MICROSOFT SQL SERVER?

解决方案

I was looking for a solution to this, when I stumbled upon this link: code.msdn.microsoft/Demo-of-ADONET-POCO-with-140ad3ad

Place the SSDLToSQLite3.tt file in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\DBGen and you should be able to choose this as the DDL Generation Template in the Entity Designer.

Once you do that, the model will create SQL suited for SQLite.

更多推荐

生成SQL从实体框架模型SQLite数据库

本文发布于:2023-07-15 12:59:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1111368.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:实体   框架   模型   数据库   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!