我正在尝试使用新的Mono 2.6 SqlMetal工具为简单的Sqlite数据库创建DBML文件。架构非常简单,如下所示:
CREATE TABLE Tags (
Id INTEGER PRIMARY KEY,
TagName TEXT,
Description TEXT);
CREATE TABLE Trends (
TagId INTEGER NOT NULL,
Timestamp DATETIME NOT NULL,
Value TEXT,
PRIMARY KEY (tagid, timestamp));
我正在尝试使用以下内容创建DBML文件:
sqlmetal.exe /conn:"Data Source=MyDatabase.db" /namespace:MyNamespace /provider:Sqlite /dbml:MyDatabase.dbml
我得到以下输出:
>>> Reading schema from SQLite database
<<< Writing file 'MyDatabase.dbml'
sqlmetal failed:System.InvalidOperationException: There was an error reflecting type 'DbLinq.Schema.Dbml.Database'. --->
System.InvalidOperationException: DbLinq.Schema.Dbml.Database is inaccessible due to its protection level. Only public types can be processed
at System.Xml.Serialization.ReflectionHelper.CheckSerializableType (System.Type type, Boolean allowPrivateConstructors ) [0x00000] in <filename unknown>:0
at System.Xml.Serialization.XmlReflectionImporter.ImportClassMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00000] in <filename unknown>:0
at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00000] in <filename unknown>:0
at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00000] in <filename unknown>:0
at System.Xml.Serialization.XmlSerializer..ctor (System.Type type, System.Xml.Serialization.XmlAttributeOverrides overrides, System.Type[] extraTypes, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00000] in <filename unknown>:0 at System.Xml.Serialization.XmlSerializer..ctor (System.Type type) [0x00000] in <filename unknown>:0
at DbLinq.Schema.Dbml.DbmlSerializer.Write (System.IO.Stream xmlStream, DbLinq.Schema.Dbml.Database dbml) [0x00000] in <filename unknown>:0
at DbMetal.Generator.Implementation.Processor.WriteSchema (DbLinq.Schema.Dbml.Database dbSchema, ISchemaLoader schemaLoader, DbMetal.Parameters parameters) [0x00000] in <filename unknown>:0
at DbMetal.Generator.Implementation.Processor.ProcessSchema (DbMetal.Parameters parameters) [0x00000] in <filename unknown>:0
我可以使用/ code选项创建C#代码文件,但在生成DBML时总是会失败。
我是否错过了一个微妙的命令行选项,或者这个新版本的SqlMetal不能用于Sqlite?
答案 0 :(得分:2)
&lt; sheepish-grin&gt;您认为我之前没有尝试过生成DBML文件吗?&lt; / sheepish-grin&gt;
简短版本:这是你遇到的一个错误,没有解决方法。我已将其归档为http://code.google.com/p/dblinq2007/issues/detail?id=171。
更长的版本:似乎没有一个简单的解决方案(除了“jettison System.Xml.Serialization”),因为引用的DbLinq.Schema.Dbml.Database
类型不能从{{1}公开因为明显的原因。由于存在不同的错误,在Linux下使用DbMetal.exe构建DbLinq的“解决方法”不起作用。
很抱歉给您带来不便。