[Mono-dev] EF fails with NotImplementedException

Eddy Zavaleta eddy at mictlanix.org
Tue Oct 23 01:26:45 UTC 2012


Hi,

I was trying to run a simple EF app using Mono 3.0 on Mac OS X but I got
this error:

Unhandled Exception:
System.NotImplementedException: The requested feature is not implemented.
  at System.Data.Common.DbProviderFactories.GetFactory
(System.Data.Common.DbConnection connection) [0x00000] in <filename
unknown>:0
  at System.Data.Entity.Core.Common.DbProviderServices.GetProviderFactory
(System.Data.Common.DbConnection connection) [0x00000] in <filename
unknown>:0
  at
System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInvariantName
(System.Data.Common.DbConnection connection) [0x00000] in <filename
unknown>:0
  at System.Data.Entity.Internal.InternalConnection.get_ProviderName ()
[0x00000] in <filename unknown>:0
  at System.Data.Entity.Internal.LazyInternalContext.get_ProviderName ()
[0x00000] in <filename unknown>:0
  at System.Data.Entity.Internal.DefaultModelCacheKeyFactory.Create
(System.Data.Entity.DbContext context) [0x00000] in <filename unknown>:0
  at System.Data.Entity.Internal.LazyInternalContext.InitializeContext ()
[0x00000] in <filename unknown>:0
  at System.Data.Entity.Internal.InternalContext.Initialize () [0x00000] in
<filename unknown>:0
  at
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType
(System.Type entityType) [0x00000] in <filename unknown>:0
  at System.Data.Entity.Internal.Linq.InternalSet`1[EFTest.User].Initialize
() [0x00000] in <filename unknown>:0
  at
System.Data.Entity.Internal.Linq.InternalSet`1[EFTest.User].GetEnumerator
() [0x00000] in <filename unknown>:0
  at
System.Data.Entity.Infrastructure.DbQuery`1[EFTest.User].System.Collections.Generic.IEnumerable<TResult>.GetEnumerator
() [0x00000] in <filename unknown>:0
  at EFTest.MainClass.Main (System.String[] args) [0x00018] in
/Users/eddy/Projects/EFTest/EFTest/Main.cs:46


The same code works fine with MS .NET.


// Main.cs
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Common;
using System.Data.Entity;
using System.Data.SqlClient;
using System.Linq;

namespace EFTest
{
[Table("user")]
 class User
{
[Key]
 [Column("user_id")]
public string UserName { get; set; }

 public string Password { get; set; }

public string Email { get; set; }
 public override string ToString ()
{
 return string.Format ("{0}, {1}, {2}", UserName, Password, Email);
}
 }

class SampleEntities : DbContext
{
 public SampleEntities (DbConnection conn) : base(conn, true)
{
}
 public DbSet<User> Users { get; set; }
}

class MainClass
{
public static void Main (string[] args)
 {
var em = new SampleEntities (new SqlConnection ("server=localhost;" +
 "database=ef_demo;" +
"uid=developer;" +
"pwd=123456;"));

foreach (var item in em.Users) {
Console.WriteLine (item);
 }
}
}
}

// ef_test.sql
CREATE DATABASE ef_test;
GO

USE ef_test;
GO

CREATE TABLE [user] (
  user_id varchar(20) NOT NULL,
  password varchar(40) NOT NULL,
  email varchar(250) NOT NULL,
  PRIMARY KEY (user_id)
);
GO

INSERT INTO [user] VALUES ('admin', '123456', 'admin at company.com'),
  ('user', '123456', 'user at company.com'),
  ('guest', '123456', 'guest at company.com');
GO


Thanks,
-- 
Eddy Zavaleta
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20121022/27051844/attachment.html>


More information about the Mono-devel-list mailing list